JavaScript Coder

password validation

Javascript password validation alphanumeric string

In case you want to allow only alpha-numeric characters in your password, here is the validation to check that condition: Alpha-numeric regular expression test Here is the function to test whether the inut matches an alphanumeric pattern: function validateAlphaNumericPassword(pwd) { var re = /^[a-z0-9]+$/i return re.test(pwd) } Alphanumeric with hyphen Sometimes, you may want to allow some characters like hyphen ( - ) in addition to alpha-numeric characters. Here is the validation

Continue Reading →

Javascript password validation using regular expression

Suppose you want to validate whether the password has at least one number other than alphabetic characters. Here is the regular expression to validate that condition Check at least one number exists in the password Here is the regular expression validation that confirms at least one number exists in the password function validatePassword(pwd) { var re = /^(?=.*\d).+$/ return re.test(pwd) } This regular expression makes use of (positive lookahead assertion)[https://stackoverflow.com/a/1570916/1198745] (?

Continue Reading →