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