locked
Regex for password validation RRS feed

  • Question

  • User-46109667 posted

    Hi All,

    I want to validate password using jquery & regex.

    • Atleast one char
    • atleast one special char
    • atleast one numeric val
    • minimum length 8

    Thanks in advance.

    Monday, October 24, 2016 5:48 PM

All replies

  • User-691209617 posted

    Hi,

    Atleast one numeric val, (?=.*?[0-9])

    At least one special character, (?=.*?[#?!@$%^&*-])

    Minimum 8 in length .{8,} (with the anchors)

    Atleast one character ^\d*[a-zA-Z][a-zA-Z0-9]*$
    Monday, October 24, 2016 5:58 PM
  • User-271186128 posted

    Hi RagavanB,

    I want to validate password using jquery & regex.

    • Atleast one char
    • atleast one special char
    • atleast one numeric val
    • minimum length 8

    You could try to use the following regular Expression:

    ^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$

    (/^
    (?=.*[A-Za-z])             //should contain at least one char
    (?=.*[$@$!%*#?&]) //Should contain at least one special char
    (?=.*\d)                //should contain at least one digit
    [A-Za-z\d$@$!%*#?&]{8,}    //should contain at least 8 from the mentioned characters
    $
    /)

    More details about Regular Expression Syntax, see: https://msdn.microsoft.com/en-us/library/ae5bf541(v=vs.100).aspx

    JQuery validation: http://www.aspsnippets.com/Articles/Password-Strength-validation-example-using-JavaScript-and-jQuery.aspx

    Best regards,
    Dillion

    Tuesday, October 25, 2016 11:27 AM