Validate phone number with JavaScript

前端 未结 26 2295

I found this code in some website, and it works perfectly. It validates that the phone number is in one of these formats:
(123) 456-7890 or 123-

26条回答
  •  野的像风
    2020-11-22 05:26

    Just wanted to add a solution specifically for selecting non-local phone numbers(800 and 900 types).

    (\+?1[-.(\s]?|\()?(900|8(0|4|5|6|7|8)\3+)[)\s]?[-.\s]?\d{3}[-.\s]?\d{4}
    

提交回复
热议问题