Question

Error on regex form field validation for cell phone and landline numbers

  • 14 July 2022
  • 1 reply
  • 29 views

Badge +1

In my coutry number without the international prefix are 9 numbers length, and begin with 2 or 9[1|3|2|5] and is as it follows, however it is let numbers like 222222 being validated… what am i missing?

/^[2|9]{1}\d{8}$/.test(e)


1 reply

Hi Plom!
Thanks for bringing up this question.

 

Valid numbers and real numbers are not necessarily the same thing. You can have a valid number that is not a real number.
 
In order to validate numbers according to pre-determined rules, you’ll need a bit of JavaScript with some RegEx. This would get you a valid number. Example: All New Zealand numbers need to start with “64”.
 
This Unbounce Community post found here should point you in the right direction for custom validation with RegEx.
 
If you want to further make sure the number is real, you’ll need a 3rd party that can actually make the check for you and returns a response.

There are a few third-party services that do this kind of check for the US and UK. There are probably some that do it for other locations as well, 
 
Please note to access the script shown on the Unbounce Community💡 post, you may need to create a Community account - not to worry as it is free! 

Thanks :) 
Cecilia 
 

Reply