Form Validation


So you want to validate a form. Usually this just involves checking that required fields have been entered. Put this function in your header JavaScript, copy'n'paste the "if" as many times as you need, and edit the field names and messages:

function validate(form) {
  if (form.Surname.value == "") {
    alert('"Surname" is a required field. Please enter your surname and try again.')
    return false
  return true

Now add the following attribute to your form element:

onSubmit="return validate(this)"