cancel
Showing results for 
Search instead for 
Did you mean: 

US phone validation in magento 2

US phone validation in magento 2

Hi,
I have checked in the validation rules list and shows phoneUS, validate-phoneStrict and validate-phoneLax.

Can anyone suggest which is the correct one to validate the US phone number.
and also give example for the phoneUS validation rule correct number format.

Thanks,
Kiran.

1 REPLY 1

Re: US phone validation in magento 2

Both  validate-phoneStrict  and  validate-phoneLax  validate the same way. And also, their validation codes are the same.

ex - Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.

 

But the main difference is -

 

validate-phoneStrict  - It will accept the US phone number such as

(123) 456-7890, (123 456-7890, 123) 456-7890, 123456-7890, 123 456-7890.

 

validate-phoneLax It will  not accept the US phone number such as

 (123 456-7890, 123) 456-7890. It basically restrict the user to either use open and close both brackets or don't use any of them.

 

If problem solved click kudos.