Phone Number Validation Javascript

后端 未结 5 1083
情深已故
情深已故 2020-12-09 21:40

I want users to allow only phone numbers in following format

xxx-xxx-xxxx or xxxxxxxxxx all digits only . Can some one suggest a regular expression to do this ?

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 22:11

    Use this :

    /^(1-?)?(([2-9]\d{2})|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/

提交回复
热议问题