js password validation regex
const regexPass = /(?=.*[!#$%&?^*@~() "])(?=.{8,})/;
//eight char or longer and must have a special character
js password validation regex
const regexPass = /(?=.*[!#$%&?^*@~() "])(?=.{8,})/;
//eight char or longer and must have a special character
how can i validate a password without regex in js
function validate() {
var p = document.getElementById('pass').value
var errors = []
//if (p.length < 8) {
// errors.push("Your password must be at least 8 characters")
//}
if (p.search(/[a-z]/) < 0) {
errors.push("Your password must contain at least one lowercase letter.")
}
if (p.search(/[A-Z]/) < 0) {
errors.push("Your password must contain at least one uppercase letter.")
}
if (p.search(/[0-9]/) < 0) {
errors.push("Your password must contain at least one digit.")
}
if(p.search(/[\!\@\#\$\%\^\&\*\(\)\_\+\.\,\;\:\-]/) < 0) {
errors.push("Your password must contain at least one special character.")
}
if (errors.length > 0) {
document.getElementById("errors").innerHTML = errors.join("<br>")
return false;
}
return true;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us