Lethal Left Eye Lethal Left Eye - 6 months ago 47
Javascript Question

JavaScript Validate Phone Number Using Regex

Greetings overflowers,

I'm trying to write a regular expression to validate phone numbers of the form ########## (10 digits)
i.e. this is these are cases that would be valid: 1231231234 or 1111111111. Invalid cases would be strings of digits that are less than 10 digits or more than 10 digits.

The expression that I have so far is this:

Unfortunately, it does not properly validate if the string is 11+ digits long.

Does anyone know of an expression to achieve this task?


You need to use ancors, i.e.