function isFilled(elm) {
  // check that this form element has a value
  if (elm.value == "" || elm.value == null) return false;
  else return true;
}

function isEmail(elm) {
  // check that the provided address has an @ sign and at least one . and no spaces
  if (elm.value.indexOf("@") != "-1" && elm.value.indexOf(".") != "-1" && elm.value.indexOf(" ") == "-1") return true;
  else return false;
}

function isReady() {
  // this check doesn't do form re-focusing, like the contact form does
  // check that a name was provided
  if (isFilled(form.contact_name) == false) {
    alert("You forgot to provide your name");
    return false;
  }
  // check that a valid e-mail address was provided
  if (isFilled(form.contact_email) == false) {
    alert("You forgot to provide your e-mail address");
    return false;
  }
  if (isEmail(form.contact_email) == false) {
    alert("The e-mail address you provided looks invalid");
    return false;
  }
  // check that the relation to the production was provided
  if (isFilled(form.contact_relation) == false) {
    alert("You forgot to provide your relation to the show");
    return false;
  }
  // check that an update was provided
  if (isFilled(form.notes) == false) {
    alert("You forgot to provide the updated information");
    return false;
  }
  // return true to have the form continue processing
  return true;
}

// add javascript handling to the form, if possible
if (form = document.getElementById('update')) {
  form.onsubmit = isReady;
}

