Hey there! I've been working on a JavaScript script to test password field validation. As of now, I have successfully made the script display an alert when the requirements are not met. However, I am now facing an issue regarding what action to take once all the requirements are satisfied. I tried to create a condition that triggers a button click event upon meeting all the requirements, but unfortunately, it's not working as expected. Any tips or advice on how to solve this would be highly appreciated. Below is the code snippet I'm currently working with:
var str = passwordFieldForm;
var patt = /[a-z]/g;
var patt2 = /[A-Z]/g;
var patt3 = /[0-9]/g;
var patt4 = /[~\!@#\$%\^&*_\-\+=`\|\\(\)\{\}\[\]:;"'<>,\.\?\/]/g;
var result = patt.test(str);
var result2 = patt2.test(str);
var result3 = patt3.test(str);
var result4 = patt4.test(str);
if (!result) {
alert("Needs a lowercase letter");
}
if (!result2) {
alert("Needs an Uppercase Letter");
}
if (!result3) {
alert("Needs a Number.");
}
if (!result4) {
alert("Needs a special character");
}
if (result && result2 && result3 && result4) {
document.getElementById("kioskform:broswerPasswordSubmit").click();
}