Phone number form validation is not about rejecting numbers; it is about getting one you can actually use. The most common mistake is not the regex but the message. “Invalid phone” forces people to guess; “The area code is missing” tells them what to fix. This article covers four decisions: ask for the country, separate error types, write the message, and decide what to do with the result.
Ask for the country: without it, a national number is ambiguous
A number like 11 5555-1234 could belong to Buenos Aires or to another country where that sequence is plausible. The E.164 international format (ITU-T) removes the ambiguity because it starts with + and the country code, but few people type it that way unprompted. That is why good forms offer a country selector beside the field, or accept the + when someone types it.
Two cautions. First, do not lock the field to a single country: someone in Madrid may give you an Argentine mobile. Second, do not infer the country from the visitor’s IP and treat it as fact: an IP describes a network, not where the phone number comes from. Suggesting it as a default is fine; imposing it is not. In our API the default country (default_country, a two-letter ISO code) is sent explicitly and is not inferred from the IP.
Separate the errors: they do not all get fixed the same way
A single “invalid” blends different situations, and each calls for a different action. Phone input libraries already split them: intl-tel-input, for instance, distinguishes an invalid country code, a number that is too short and one that is too long. You can use a similar split, in three groups:
- Missing information: no country, or an empty number. Fixed by asking for the data.
- Format error: extra or missing digits, letters, a prefix that does not fit the chosen country. Fixed by showing the expected format.
- Could not be checked: the validation service did not answer or lacks the data to decide. This is not the person’s mistake and should not block them.
The third group is the one most often skipped. A check that cannot conclude does not mean the number is fake; treating it as the person’s error is the quickest way to lose a legitimate contact.
Write the message so someone can act on it
Guidewire’s design guidance puts it well: error text should guide and show a solution rather than leave people guessing. For phone numbers that means short messages with a concrete example and no blame:
- “Choose the number’s country so we can check it.” (missing country)
- “A few digits are missing. In Argentina, a mobile has the area code plus 8 more digits; for example, 11 2345-6789.” (too short)
- “This number seems to have extra digits. Check that the country code is not repeated.” (too long)
- “We could not check the number right now. You can continue and we will review it later.” (no result)
Also keep what the person typed: do not clear the field on failure, do not change the number silently, and show the error next to the field, not only at the top of the form. Use the phone input type so mobile opens the numeric keypad, and if you format while typing, make sure editing does not make the cursor jump.
Connect the results to the form
Browser-side validation is a usability aid; the one that counts runs on your server, because anyone can bypass the form. A reasonable flow: the person picks a country and types the number, your server normalizes it to E.164 and calls the validation, and the form shows the message that matches the result.
With the ByeBouncer API, that means sending the phone with default_country when the number is national and reading what comes back: whether the format is valid, the country, the range operator and the line type. What you do with it is up to you: ask for a correction on an invalid format, accept with a notice when the operator could not be determined, or save the contact and flag it for review. There is no universal rule.
What this does not do
Worth saying plainly. ByeBouncer validates format, country, range operator and line type, and optionally checks mobile network status. It does not verify that the person owns the number, does not send SMS codes and does not confirm whether a number has WhatsApp. If you need to prove someone controls a line, you need a one-time code (OTP) sent through your own channel; format validation helps beforehand, so you do not spend sends on mistyped numbers.
In short
Ask for the country, normalize to E.164, separate the person’s mistakes from no-result cases, and write messages that say what to fix and how. That turns the form from a rejection filter into a help for leaving a usable phone number.
See how phone validation works →
Create a free account and try the API →