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-
What I would do is ignore the format and validate the numeric content:
var originalPhoneNumber = "415-555-1212"; function isValid(p) { var phoneRe = /^[2-9]\d{2}[2-9]\d{2}\d{4}$/; var digits = p.replace(/\D/g, ""); return phoneRe.test(digits); }