Sunday, 8 April 2012

Javascript : Password Validation with Regular expression.

Hi viewers,

This topic- Password Validation with Regular expression.

Its 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 Validation with Regular expression.

/* 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})$/;
        return true;
        pwdelem.focus(); //Set focus to the given source element id ( textbox or password) ,it is optional .
        return false;


Any help ,ping me.

No comments:

Post a Comment