feat: created a base form with some validators

This commit is contained in:
2021-11-29 00:10:59 +01:00
parent 3bc5f0e6f5
commit ec451d82c0
10 changed files with 248 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
function validate_form() {
var pass = validate_password();
return validate_confirm() && pass;
}
function validate_confirm() {
var password = document.getElementById("newpassword");
var confirm = document.getElementById("confirm_password");
if (password.value != confirm.value) {
confirm.classList.add("errorinput");
document.getElementById("confirm-msg").classList.add("fade");
return false;
}
confirm.classList.remove("errorinput");
document.getElementById("confirm-msg").classList.remove("fade");
return true;
}
function validate_password() {
var password = document.getElementById("newpassword");
var reg = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/;
if (reg.test(password.value) != true) {
password.classList.add("errorinput");
document.getElementById("password-msg").classList.add("fade");
return false;
}
password.classList.remove("errorinput");
document.getElementById("password-msg").classList.remove("fade");
return true;
}