Validate U.S Phone Numbers using JavaScript Regular expression.

15 Comments

279804967 668397cde9 m Validate U.S Phone Numbers using JavaScript Regular expression.
Photo credit: aussiegall

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

article clipper vert Validate U.S Phone Numbers using JavaScript Regular expression.
 

zParacha.com is in iBlogCup final!

No Comments

Folks I am very excited to inform you that with all your votes zParacha.com is now in the final of the iBlogCup. 64 blogs participated and now we have two best blogs competing for the cup.

cup zParacha.com is in iBlogCup final!

Thank you all who voted for me during this competition. It was a very good contest and some very good blogs were nominated for this competition. Now is your chance to vote for the best blog. I request you to spare few more minutes and vote for me in the final round. The polls close at midnight 02/27/2008 (Wednesday). Don’t delay vote today! Just click here and cast your vote now.

article clipper vert zParacha.com is in iBlogCup final!
 

Win 250 Entrecard credits to promote your blog.

3 Comments

winEcard Win 250 Entrecard credits to promote your blog.

Entrecard is one of the latest blog promotion services that is attracting lot of bloggers. Entrecard is a relatively new blog promotion website but it is different (and better) than other similar websites. You have total control on how to use this service.

I used to have BlogRush widget on my blog but I did not get any significant traffic from BlogRush. When I read about Entrecard last month I instantly started using this service. I am already seeing considerable number of visitors coming to my blog through Entrecard.

The concept is very simple. You create your virtual business card using a 125×125 pixel image of your choice and place a widget on your blog. When other Entrecard members visit your blog they can “drop” their cards. For each card drop you receive one Entrecard “credit”. The member who dropped the card will also receive one “credit”.
More

article clipper vert Win 250 Entrecard credits to promote your blog.
 

Validate Zip code using JavaScript Regular expression

7 Comments

zipcode 300x199 Validate Zip code using JavaScript Regular expression

Zip Code

Continuing with my series of JavaScript regular expression today we will see how easy it is to validate zip code using regular expression in JavaScript. Previously we talked about validating email and Social Security number using JS regex.

In today’s post I’ll show you how to use JavaScript regular expression to validate zip code. Let me first show you the JS code.


function validateZipCode(elementValue){
    var zipCodePattern = /^\d{5}$|^\d{5}-\d{4}$/;
     return zipCodePattern.test(elementValue);
}

Explanation:

The argument to this method is the zip code you want to validate.

In the method body we define a variable (‘zipCodePattern’) and assign a regular expression to it.

ZipCode format: The regular expression for zip code is

More

article clipper vert Validate Zip code using JavaScript Regular expression
 

How to validate Social Security Number (SSN) using JavaScript Regular Expressions

2 Comments

When I wrote the JS regular expression article last week I had no idea that it will attract so many visitors. Not only did so many people read this post, many more visited my blog searching for other regular expressions. So I decided to write few more posts about JavaScript regular expressions and how to use them to validate Social Security number, zip code, phone number and numeric data. I’ll divide these into smaller posts discussing one regular expression per post to keep it simple for the readers.

In today’s post I’ll show you how to use JavaScript regular expression to validate Social Security number. Let me first show you the JS code.

    function validateSSN (elementValue){
       var  ssnPattern = /^[0-9]{3}\-?[0-9]{2}\-?[0-9]{4}$/;
       return ssnPattern.test(elementValue);
   }

Explanation:

The argument to this method is the social security number you want to validate.

In the method body we define a variable (‘ssnPattern’) and assign a regular expression to it.

SNN format: The regular expression for social security number (SSN) is

More

article clipper vert How to validate Social Security Number (SSN) using JavaScript Regular Expressions
 

Automatically twitter your posts

1 Comment

Twitter is a wonderful tool to promote your blog. Typically after they publish a new post bloggers logon to their twitter account and inform their followers that they have published an interesting new post.

twitterfeed thumb2 Automatically twitter your posts

But there is a better way to promote your post. twitterfeed automatically informs your followers about your new posts. How cool is that? You publish the post, sit back and relax and twitterfeed will do the rest. Twitterfeed frequently pings your blog and if it finds a new post it automatically informs your followers about it.

Follow these simple steps to take advantage of this free service.

  • Sign up at Twitterfeed
  • Provide your twitter account information and your blog RSS feed to twitterfeed.
  • Tell it how often you want the service to check your blog for new posts.
  • From now on you don’t have to announce your new posts on twitter.

Enjoy.

This post has been submitted to Jason’s blog competition about blogging tips.

article clipper vert Automatically twitter your posts
 

Validate email address using JavaScript regular expression

91 Comments

Last month I wrote about regular expressions in Java, today I’ll show you how to use regular expression in JavaScript to validate email address.

Here is the code to validate email address in JavaScript using regular expression.

function validateEmail(elementValue){
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(elementValue);
 }

Explanation:

The argument to this method is the email address you want to validate.
In the method body we define a variable (‘emailPattern’) and assign a regular expression to it.

Email format: The regular expression for email is
More

article clipper vert Validate email address using JavaScript regular expression
 

Backlink extravaganza

3 Comments

backlink Backlink extravaganzaToday 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.

Here is how we do it.

In the comments section below enter link to one of your posts on your blog. You have till Friday night to post your comments. I’ll compile all the links and post them on my blog on Monday.

Note: I will not include links to any inappropriate blogs or posts.

If you like the idea go ahead and post your link now and feel free to spread the word among your friends and your blog readers.


article clipper vert Backlink extravaganza