mercredi 30 octobre 2019

Using if statements with an else to validate form and redirect to a new page if form is valid

hi i've got this code to validate the form which works but it doesn't carry out the else statement and direct to the page if the form is valid

function printpage() {
  if (!mandatoryText(document.getElementById('FIRSTNAME_FIELD'), 'First name')) return false;
  if (!mandatoryText(document.getElementById('LASTNAME_FIELD'), 'Last name')) return false;
  if (!mandatoryText(document.getElementById('ZIP_CODE_FIELD'), 'Post code')) return false;
  if (!mandatoryText(document.getElementById('EMAIL_FIELD'), 'Email')) return false;
  if (!isEmail(document.getElementById('EMAIL_FIELD'))) return false;
  if (!isDateOK(document.getElementById('LAST_SHOWROOM_VISIT_FIELD').value)) return false;
  if (document.getElementById('LAST_SHOWROOM_VISIT_FIELD').value != '') modifyDateFormat(document.getElementById('LAST_SHOWROOM_VISIT_FIELD'));
  document.getElementById('emvForm').submit();
  if (document.getElementById('LAST_SHOWROOM_VISIT_FIELD').value != '') modifyDateFormat(document.getElementById('LAST_SHOWROOM_VISIT_FIELD'));
  else {
    return true;
    var p1 = document.getElementById('SELECTED_PRODUCT_1_FIELD').value;
    window.location.href = "summary.html?" + "p1" + "=" + p1;
  }
}

Aucun commentaire:

Enregistrer un commentaire