Well, my cell phone number is, 0332-*******, but if I had to give it to you I would have to strip out the first zero (leading zero) and add the country code to it, +92. Thus, you can contact me using my phone number, internationally. Of course I can send my cell number, and yes, in my own country the cell number if found to be starting with a zero.
For your scenario, a masked input would be a perfect fit (
See the link[^] in Solution 1) because a script that uses the mechanism to prefix the characters is not efficient;
believe me I tried it. What if the user doesn't enter the correct input, what if user already has added the zero, or what if he hasn't, or what if he enters the country code himself?
In such cases, I would (if I had to write the application) check a Combobox (
select
in HTML) control (In most of the software development frameworks), which holds the country codes for the phone numbers. Then, you can ask the user for his own number, without the country code. User would enter the number as, 332-******* (without the zero, or country code or other same stupid
standard-based stuff). Then, I can append the +92 and store it in my database or process it. Same should be done here! It makes your life easy. ;)
Most of the giants do that, they ask you for your number without country code and give you a list of country names that you chose from and they append the country code to it.