Specifically the fields being submitted were all number fields, and as such we only want valid numbers in there.
After some Googling, I thought I’d combine what I’ve learnt on my blog.
If disabled, there is no dropdown arrow, and the selected flag is not clickable.
Also we display the selected flag on the right instead because it is just a marker of state. Instead of putting the country dropdown next to the input, append it to the specified node, and it will then be positioned absolutely next to the input using Java Script.
close:countrydropdown This is triggered when the user closes the dropdown.
The utilities script (build/js/utils.js) is a custom build of Google's libphonenumber which enables the following features: International number formatting/validation is hard (it varies by country/district, and we currently support ~230 countries).
Note: there is currently a bug in Mobile Safari which causes a crash when you click the dropdown arrow (a CSS triangle) inside an input group.
We had an issue raised where a user wasn’t happy that the validation was happening on submit, requiring them to spend time filling out several more details before being told they made a mistake.
If you like it, please consider making a donation, which you can do from the demo page. I recommend you get, store, and set numbers exclusively in this format for simplicity - then you don't have to deal with handling the country code separately, as full international numbers include the country code information.
The second part of the JSON string is firing an APEX error message on the same page item.
countrychange This is triggered when the user selects a country from the dropdown.
See an example here: Country sync open:countrydropdown This is triggered when the user opens the dropdown.