I need to validate a form in JavaScript where the phone number that a user provides is in the format of either (###)###-####
or (###) ###-####
with the difference being the space after the )
. Why? I have no idea. It makes no sense to me and no phone number should ever look like that in the United States which for my purpose, it will be.
Anyways, the code that I'm currently using looks like this:
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
This will ensure a phone number of the format: ###-###-####
.
hey, i think this regex will help you: