08 April, 2012

Manoj.Blog: Javascript : Password Validation with Regular expr...

Manoj.Blog: Javascript : Password Validation with Regular expr...: Hi viewers, This topic - Password Validation with Regular expression. Its a daily process for web developers to validating the passwo...

Manoj.Blog: FACEBOOK Link Integration to your Website. Share D...

Manoj.Blog: FACEBOOK Link Integration to your Website. Share D...: Copy the below given code inside your Html Page Tag and enjoy the facebook share plugin. <a name="fb_share" type="button"  share_...

How to validate Password with Regular expression.

In Today article,  we will see how to validate password with Regular expressionIts a daily process for web developers to validating the password with certain rules.With java script client side validate can be achieved. Below the code will help you to validate the password which contain at least one Letter , one Number & one special character. The password length must be within a given range.



/* Password must be at least one char, one special char & one digit & the length must be given*/
function validatePassword(pwdelem,alertmsg){
    var password_expression=/^((?=.*[a-zA-Z])(?=.*\d)(?=.*[#@%$]).{6,20})$/;
    if(pwdelem.value.match(password_expression)){
        return true;
    }
    else{
        alert(alertmsg);
        pwdelem.focus(); //Set focus to the given source element id ( textbox or password) ,it is optional .
        return false;
    }
}