Stucked how to apply validation if old password not entered. Need validation if anyhow user forgot to enter the old password. Thanks in advance.
$(document).ready(function() {
$("#submitBtn").click(function(){
validate();
});
});
function validate() {
var password1 = $("#password1").val();
var password2 = $("#password2").val();
if(password1 != password2) {
$(".error-msg").html("Password and confirmation password do not match.").show();
}
else {
$(".error-msg").html("").hide();
ValidatePassword();
}
}
function ValidatePassword() {
var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,}$/;
var txt = document.getElementById("password1");
if (!regex.test(txt.value)) {
$(".error-msg").html("The password does not meet the password policy requirements.").show();
} else {
$(".error-msg").html("").hide();
window.location.href='change-password-msg.html';
}
}