I want to make sure phone numbers are entered correctly. They are UK numbers and cannot contain any symbols or letters. They must be 11 in length.
So I have tried the following:
else if (phone == null || !phone.toString().match(/^[-]?\d*\.?\d*$/)){
But this actually allows any length and even blank input.
What should I do to validate phone numbers? I'm not that experienced with Javascript.
The regexp to match exactly 11 digits is /^\d{11}$/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With