Skip to content

Commit

Permalink
fix (submit) : check inputs, validate form (OpenClassrooms-Student-Ce…
Browse files Browse the repository at this point in the history
  • Loading branch information
codexarama committed Mar 8, 2021
1 parent e014fb1 commit 7fd726b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions starterOnly/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,41 @@ function closeConfirm() {
bground.style.display = 'none';
}

// VALIDATION FORMULAIRE

form.addEventListener('submit', function (e) {
e.preventDefault();

const emptyInputs = (
firstName &&
lastName &&
email &&
birthdate &&
quantity
).value.trim();

if ((emptyInputs) && (checkbox1.checked)) {
// submitBtn.disabled = false;
// errorForm.innerHTML = '';
modalBody.style.display = 'none';
confirm.style.opacity = '1';
} else if (
validFirstName(firstName) &&
validLastName(lastName) &&
validEmail(email) &&
validBirthdate(birthdate) &&
validQuantity(quantity) &&
validConditions(checkbox1)
) {
// submit.disabled = false;
// submit.style.backgroundColor = 'limegreen';
// errorForm.innerHTML = '';
} else {
// submit.disabled = true;
submit.style.backgroundColor = 'grey';
errorForm.innerHTML = 'Veuillez renseigner tous les champs';
}
});

// VALIDATION DES INPUTS

Expand Down

0 comments on commit 7fd726b

Please sign in to comment.