20 lines
572 B
JavaScript
20 lines
572 B
JavaScript
const form = document.getElementById("login-form");
|
|
form.addEventListener('submit', function (e) {
|
|
e.preventDefault();
|
|
|
|
// validate form
|
|
const p1 = document.querySelector('input[name="password"]');
|
|
const p2 = document.querySelector('input[name="checked_password"]');
|
|
|
|
if (p1.value == p2.value) {
|
|
console.log("Passwords match");
|
|
form.submit();
|
|
} else {
|
|
console.log("Passwords do not match");
|
|
// do something with the forms
|
|
p1.setAttribute('style', 'border: 1px solid red');
|
|
p2.setAttribute('style', 'border: 1px solid red');
|
|
}
|
|
});
|
|
|