﻿function validate_form() {
    /*
        1: This validation file is called from the script line in the <head> section of the entry form.
        2: Simple form validation is checked by the name of each field.
        3: To replicate simple mandatory validation on a checkbox you need to replicate from the if
           statement to the closing} and put the name of the form field in. E.g. if your new field is 
           called 'postcode', then you need some new validation as follows:
        
        
           if (document.myform.postcode.value == "") {
              errorString += "* Please fill in the 'Postcode' field.\n";
              valid = false;
           }
         
    */
    valid = true;
    var errorString = "";
    

    if (document.myform.first_name.value == "") {
        errorString += "* Please fill in the 'First Name' field.\n";
        valid = false;
    }
    if (document.myform.last_name.value == "") {
        errorString += "* Please fill in the 'Last Name' field.\n";
        valid = false;
    }
    if (document.myform.email.value == "") {
        errorString += "* Please fill in the 'Email Address' field.\n";
        valid = false;
    }
    if (document.myform.phone.value == "") {
        errorString += "* Please fill in the 'Phone Number' field.\n";
        valid = false;
    }
    if ((document.myform.answer[0].checked == false) && (document.myform.answer[1].checked == false) && (document.myform.answer[2].checked == false)) {
        errorString += "* Please choose one of the 3 possible answers.\n";
        valid = false;
    }

    if (valid == false)
        alert(errorString);

    return valid;
}