Sunday, December 23, 2007

Email Validation

Here is a sample code for validating email address using JavaScript regular expression.

var Email = "username@domain.com";
var flag = /^[a-zA-Z0-9_.]+@[a-zA-Z0-9]+[.][a-zA-Z]+[a-zA-Z.]*$/.test(Email);
if(flag){
alert('Valid email address');
}else
alert('Invalid email address');

No comments:

Post a Comment

Yahoo! News: Technology News