// 1 line password validation for
// Uppercase, Lowercase, Number, Special Character
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js"></script>
$("#submit_id").click(function() {
var pattern = /^.*(?=.{8,})(?=.*d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%&]).*$/;
if(!pattern.test($("#pswd").val())){
alert("INVALID PASSWORD");
}else{
alert("You have a strong PASSWORD");
}
});
var pass = "f00Bar!";
var strength = 1;
var arr = [/.{5,}/, /[a-z]+/, /[0-9]+/, /[A-Z]+/];
jQuery.map(arr, function(regexp) {
if(pass.match(regexp))
strength++;
});