jquery to validate phone number

后端 未结 9 1817
情话喂你
情话喂你 2020-12-01 06:34

I want to validate phone numbers like (123) 456-7890 or 1234567890 How should be the \'matches\' condition be written in the following code?

form.validate({         


        
9条回答
  •  粉色の甜心
    2020-12-01 07:03

    I tried the below solution and it work fine for me.

    /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/
    

    Tried below phone format:

    • +(123) 456 7899
    • (123) 456 7899
    • (123).456.7899
    • (123)-456-7899
    • 123-456-7899
    • 123 456 7899
    • 1234567899

提交回复
热议问题