J
John Smith
Hello all:
I was wondering if someone had a good regular expression
for a phone number. I came up w/on that does validation to
the point of having an optional area code, but I would like
to restrict the length of the entire number entered. For
example, if they enter an eight digit number it would not
match but a seven digit number would. The following is
what I have been trying but it does not work:
[0-9]{3}[-| ]?[0-9]{4}
Which says 3 digits then either a dash, space or nothing,
followed by four digits.
Any ideas?
Thanks,
John
I was wondering if someone had a good regular expression
for a phone number. I came up w/on that does validation to
the point of having an optional area code, but I would like
to restrict the length of the entire number entered. For
example, if they enter an eight digit number it would not
match but a seven digit number would. The following is
what I have been trying but it does not work:
[0-9]{3}[-| ]?[0-9]{4}
Which says 3 digits then either a dash, space or nothing,
followed by four digits.
Any ideas?
Thanks,
John