feat: created a base form with some validators
This commit is contained in:
37
app/ui/static/js/validate.js
Normal file
37
app/ui/static/js/validate.js
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user