Validate U.S Phone Numbers using JavaScript Regular expression.
Feb 28
Javascript Javascript, RegEx, Regular Expression 15 Comments
Continuing with our JavaScript regular expression series today we will discuss JavaScript regular expression to validate U.S phone number. Previously we talked about validating email , Social Security number and zip code using JS regex.
In today’s post I’ll show you how to use JavaScript regular expression to validate U.S phone number.
Although in this article we are discussing U.S phone number format I am sure this can be applied to other phone number formats with little or no change.
Let’s begin by looking at the JavaScript code.
function validatePhoneNumber(elementValue){
var phoneNumberPattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
return phoneNumberPattern.test(elementValue);
}
Explanation:
The argument to this method is the phone number you want to validate.
In the method body we define a variable (‘phoneNumberPattern’) and assign a regular expression to it.
Phone Number format: The regular expression for phone number is More






Today I am announcing a new montly backlink giveaway. Every month I’ll invite bloggers to post a link to one of their favorite posts on their blog. I’ll then compile those links in a post on my blog. It is a win-win situation for all of us. I hope to get more traffic and you get one more avenue to showcase your posts.