You must Sign In to post a response.
  • Category: Windows

    Required Regular Expression

    I need to check password contains atleast one alpha charecter and atleast one numeric values and one special charecter..anyone know regular expression for above requirement?
  • #589176
    Hi,

    Try the code from the below link:

    http://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/



    Or you can use the below expression to match a string at least 6 characters long, with at least one lower case and at least one uppercase letter and require at least one digit or one symbol :

    ^.*(?=.{6,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\d\W]).*$

  • #589179
    hi,

    check this javascript

    <script type="text/javascript">
    function checkForm(form)
    {
    if(form.username.value == "")
    {
    alert("Error: Username cannot be blank!");
    form.username.focus(); return false;
    }
    re = /^\w+$/;
    if(!re.test(form.username.value))
    {
    alert("Error: Username must contain only letters, numbers and underscores!");
    form.username.focus(); return false;
    }
    if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value)
    {
    if(form.pwd1.value.length < 6)
    {
    alert("Error: Password must contain at least six characters!");
    form.pwd1.focus(); return false;
    }
    if(form.pwd1.value == form.username.value)
    {
    alert("Error: Password must be different from Username!");
    form.pwd1.focus(); return false;
    }
    re = /[0-9]/;
    if(!re.test(form.pwd1.value))
    {
    alert("Error: password must contain at least one number (0-9)!");
    form.pwd1.focus(); return false;
    }
    re = /[a-z]/;
    if(!re.test(form.pwd1.value))
    {
    alert("Error: password must contain at least one lowercase letter (a-z)!");
    form.pwd1.focus(); return false;
    }
    re = /[A-Z]/;
    if(!re.test(form.pwd1.value))
    {
    alert("Error: password must contain at least one uppercase letter (A-Z)!");
    form.pwd1.focus(); return false;
    }
    }
    else
    {
    alert("Error: Please check that you've entered and confirmed your password!");
    form.pwd1.focus(); return false;
    }
    alert("You entered a valid password: " + form.pwd1.value);
    return true;
    }
    </script>


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.