fac-14 / DJES

0 stars 0 forks source link

registration form client side validation #40

Open Brymon opened 6 years ago

Brymon commented 6 years ago
    // checks that anything has been entered into password fields
    if (password.validity.valueMissing || confirmPassword.validity.valueMissing) {
      error.innerHTML = "Please enter a password and confirm your password";
      error.className = "error";
      password.classList.add("incorrect-field");
      confirmPassword.classList.add("incorrect-field");
      return;
    }

  // checks that email is valid
  if (regEmail.validity.typeMismatch || regEmail.validity.valueMissing) {
    console.log("reached");
    error.innerHTML = "Please enter a valid email address";
    error.className = "error";
    regEmail.classList.add("incorrect-field");
    return;
  }

  // checks that anything has been entered into password fields
  if (password.validity.valueMissing || confirmPassword.validity.valueMissing) {
    error.innerHTML = "Please enter a password and confirm your password";
    error.className = "error";
    password.classList.add("incorrect-field");
    confirmPassword.classList.add("incorrect-field");
    return;
  }

looks like you repeat the same if statement twice @ checks that anything has been entered into password fields