regex - Regular Expression Validation for a Phone no that will accept nos,dashes and + -
I just need a regular expression that will validate the phone not entered in the text box. This textbox can only allow numbers, dashes (-) and plus (+) and can be up to 15 characters and a minimum of 11 characters. (+) Can (Optional) come only on starting the phone number.
Please answer.
The answer to your question is on:
\ +? [\ D]] {1,13} -
\ +? means "a '+' character of zero" -
[\ d -] {1,13} means 1 to 13 digits or hyphen " However, I think that you should use some more instructions. At least 8 digits may be required and the hyphen can not be either first or last:
^ (? = (. * \ D) {8,13}) \ +? (?! -) [\ d -] * (? & Lt;! -) $
Comments
Post a Comment