cancel
Showing results for 
Search instead for 
Did you mean: 

Phone number validation expression for US and International phone numbers

Phone number validation expression for US and International phone numbers

Hello,

 

I am working on a client website and they ship to US as well as International. They require the customer phone number when they place an order and want to use phone number validation. I'm aware this is built into validatoin.js by default. The problem is there are only 2 phone number validation options. Validate PhoneLAX and Validate PhoneStrict. Both of those work great if you are using a US phone number, but will tell you that international phone numbers are not real. 

 

I've spent countless hours searching for an expression that will allow me to validate both US and International phone numbers in this field with no luck. Any help would be greatly appreciated. 

 

Thanks!

 

Chris

2 REPLIES 2

Re: Phone number validation expression for US and International phone numbers

@OBusSolutions

 

Let me suggest a way to modify your validation.js in this manner which can help you out:

Add your new class and write login into this for the International and US phone number.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now

Re: Phone number validation expression for US and International phone numbers

I tried that but my expressions didn't quite work. I kept getting the validation error when I used either an international phone number OR a US number. I used this expression:

 

/\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$/.test(v);