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-
The following REGEX will validate any of these formats:
(123) 456-7890 123-456-7890 123.456.7890 1234567890
/^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/