Wednesday 24 April 2013

Regualer expression for validation form field

//Regular expression for validate eamil
var email_reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
var email = "sanjay@demo.com";
if (!email_reg.test(email))
{
    alert('Invalid email.');$("#email").focus();    return false;
}else{
alert('valid email.');
}



//Regular expression for validate date filed with dd-mm-YY
var date_reg = /^\d{1,2}\-\d{1,2}\-\d{4}$/;
var date ='22-05-2013';
if (!date_reg.test(date))
{
    alert('Invalid date.');$("#date").focus();    return false;
}else{
alert('valid date.');
}

//Regular expression for validate password with aplhanumeric charachter with min length 6 
 
var re = /^(?=.*[A-Za-z])(?=.*[0-9])(?!.*[^A-Za-z0-9])(?!.*\s).{5,12}$/;
if ( !re.test(password) )
{
alert('wrong password');
}else{
error = false;
alert('correctpassword');
}

No comments:

Post a Comment

List OF BANK PAN Numbers

List OF BANK PAN Numbers Bank/Home Loan Providers PAN Number Allahabad Bank AACCA8464F Andhra Bank AABCA7375C Axis Bank...