Tuesday, 25 August 2015

Password Validation (Contain char, digit and special symbol with 8 to 20 lenghts) using Java Script

HTML File
  
   
  <div class="lbl">Password : </div>
  <div class="ctrl" style="float: left;">
       <input type="password" name="pwd">
       <span id ="err_pword"></span>
  </div>
  
Java Script File
  
   
function pwd_validation(pwd)
{
        var reg = /^([A-z0-9!@#$%^&**-+/]{8,20})$/;
        if (pwd.value.match(reg))
        {
            document.getElementById("err_pword").innerHTML = "";
            return true;
        }
        else
        {
            document.getElementById("err_pword").innerHTML = "please enter valid Password...";  
            pwd.focus();
            return false;
        }
}
  

No comments:

Post a Comment