Validation for xxx-xxx-xxxx or (xxx)xxx-xxxx - Stack Overflow Possible Duplicate: A comprehensive regex for phone number validation Whats the regex for xxx-xxx-xxxx or (xxx)xxx-xxxx I can create regex for the first one with ^\d{3}-\d{3}-\d{4}$ but how
Regular Expression to validate xx-xxxxxxx or xxx-xx-xxxx string1 = xx-xxxxxxx How can I make the regex accept both kinds of values for the same element? The x's represent numbers only so total number of digits = 9 (anything between 0-9) total number of elements in the value is either 11 or 10 depending on which format and total number of dashes is either 2 or 1
input field with xxx-xxxxxxx-yy need to be validated I am trying with a validation for an number format and the number should be automatically replaced in the character while typing The format is: xxx-xxxxxxx-yy AND in another field "xx-xx-xx-xxx-x