function formCheck(formobj){
    // dialog message
    var alertMsg = "";
    var alertMsgTwo = "";
    var l_Msg = alertMsg.length;
    var l_MsgTwo = alertMsgTwo.length;
    var tmp = " ";
    
    if ((formobj.elements["FirstNames"].value == "") || (formobj.elements["FirstNames"].value == null)) {
                     alertMsg += " - 1. Complainant: First names" + "\n";
    }
    if ((formobj.elements["Surname"].value == "") || (formobj.elements["Surname"].value == null)) {
                     alertMsg += " - 1. Complainant: Surname" + "\n";
    }
    
    if ((formobj.elements["PhoneDay"].value == "" || formobj.elements["PhoneDay"].value == null) && (formobj.elements["PhoneAH"].value == "" || formobj.elements["PhoneAH"].value == null) && (formobj.elements["Mobile"].value == "" || formobj.elements["Mobile"].value == null) && (formobj.elements["Email"].value == "" || formobj.elements["Email"].value == null)){
        alertMsg += " - 1. Complainant: One of the contact phone numbers or a contact email address" + "\n";
    }
    if (formobj.ComplaintOnBehalf[5].checked == true){
            if ((formobj.elements["ComplaintOnBehalfOther"].value == "") || (formobj.elements["ComplaintOnBehalfOther"].value == null)) {
                     alertMsg += " - Making a complaint on behalf of another person: Other details" + "\n";
            }
    }
    if (formobj.RespActingFor[1].checked == true){
            if ((formobj.elements["RespOnBehalfOfOther"].value == "") || (formobj.elements["RespOnBehalfOfOther"].value == null)) {
                     alertMsg += " - 2. Respondent: Details of the other person that the respondent was acting on behalf of" + "\n";
            }
    }
    if (formobj.elements["AreaOfLaw"].value == "98") {
            if ((formobj.elements["RespConsultOtherDetails"].value == "") || (formobj.elements["RespConsultOtherDetails"].value == null)) {
                     alertMsg += " - 3. Complaint details: Consulted about Other details" + "\n";
            }
  
    }
    if (formobj.TriedToResolve[0].checked == true){
            if ((formobj.elements["ResolveDetails"].value == "") || (formobj.elements["ResolveDetails"].value == null)) {
                     alertMsg += " - 3. Complaint details: Details on attempts to resolve the complaint" + "\n";
            }
    }
    if (formobj.MakingComplaint[5].checked == true){
            if ((formobj.elements["PurposeOther"].value == "") || (formobj.elements["PurposeOther"].value == null)) {
                     alertMsg += " - 3. Complaint details: Details on other reasons why you are making this complaint" + "\n";
            }
    }
    if ((formobj.elements["Summary"].value == "") || (formobj.elements["Summary"].value == null)) {
                     alertMsg += " - 3. Complaint details: Summary" + "\n";
    }
    if ((formobj.elements["FullDetails"].value == "") || (formobj.elements["FullDetails"].value == null)) {
                     alertMsg += " - 3. Complaint details: Full details of your complaint" + "\n";
    }
    if ((formobj.elements["DeclarationName"].value == "") || (formobj.elements["DeclarationName"].value == null)) {
                     alertMsg += " - Complainant Declaration - Name" + "\n";
    }
    if ((formobj.elements["DeclarationDate"].value == "") || (formobj.elements["DeclarationDate"].value == null)) {
                     alertMsg += " - Complainant Declaration - Date" + "\n";
    }

    if (alertMsg.length == l_Msg) {
    }else{
        tmp = "Please complete the following fields:\n" + alertMsg;
        alertMsg = tmp;
    }
    var regexp = /^\d+$/;
    if (formobj.elements["DOBDay"].value != "") {
        if ((formobj.elements["DOBDay"].value.length > 2) || (formobj.elements["DOBDay"].value > 31) || ((formobj.elements["DOBDay"].value > 29) && (formobj.elements["DOBMonth"].value == "02")) || ((formobj.elements["DOBDay"].value > 30) && (formobj.elements["DOBMonth"].value == "09")) || ((formobj.elements["DOBDay"].value > 30) && (formobj.elements["DOBMonth"].value == "04")) || ((formobj.elements["DOBDay"].value > 30) && (formobj.elements["DOBMonth"].value == "06")) || ((formobj.elements["DOBDay"].value > 30) && (formobj.elements["DOBMonth"].value == "11")) ||  (regexp.exec(formobj.elements["DOBDay"].value) == null))
        {
            alertMsg += "\nThe day, " + formobj.elements["DOBDay"].value + ", in 1. Complainant: Date of birth is invalid.  Please change the day or the month to ensure the date is valid.\n";
        }
    }
    
    var CurDate1 = new Date();
    
    if (formobj.elements["DOBYear"].value != "") {
        if ((formobj.elements["DOBYear"].value.length > 4) || (formobj.elements["DOBYear"].value.length < 4) || (formobj.elements["DOBYear"].value < 1900) || (formobj.elements["DOBYear"].value > CurDate1.getYear()) || (regexp.exec(formobj.elements["DOBYear"].value) == null)){
            alertMsg += "\nThe year, " + formobj.elements["DOBYear"].value + ", in 1. Complainant: Date of birth is invalid.  Please change the year to a valid year in yyyy format eg 1979.\n";
        }
    }
    if (((formobj.elements["DOBDay"].value != "") && (formobj.elements["DOBYear"].value == "")) || ((formobj.elements["DOBDay"].value != "") && (formobj.elements["DOBMonth"].value == "")) || ((formobj.elements["DOBDay"].value != "") && (formobj.elements["DOBMonth"].value == "00")) || ((formobj.elements["DOBYear"].value != "") && (formobj.elements["DOBDay"].value == "")) || ((formobj.elements["DOBYear"].value != "") && (formobj.elements["DOBMonth"].value == "")) || ((formobj.elements["DOBYear"].value != "") && (formobj.elements["DOBMonth"].value == "00")) || (((formobj.elements["DOBMonth"].value != "") && (formobj.elements["DOBMonth"].value != "00")) && (formobj.elements["DOBDay"].value == "")) || (((formobj.elements["DOBMonth"].value != "") && (formobj.elements["DOBMonth"].value != "00")) && (formobj.elements["DOBYear"].value == ""))){
         alertMsg += "\n1. Complainant: Date of birth is partially filled out.  Please fill in the full details of Date of birth.\n";
    }

    if ((formobj.elements["DeclarationDate"].value == "") || (formobj.elements["DeclarationDate"].value == null)){
    }else{
        var CurDate = new Date();
        var CurrentDate = "";
        var CurrentDate2 = "";
        var CurDayNum = CurDate.getDate();
        var CurDay = "";
        var CurMonthNum = CurDate.getMonth();
        CurMonthNum = CurMonthNum + 1
        var CurMonth = "";
    
        if (CurDayNum < 10){
            CurDay = "0" + CurDayNum;
        }
        else
        {
            CurDay = CurDayNum;
        }
        if (CurMonthNum < 10){
            CurMonth = "0" + CurMonthNum;
        }
        else
        {
            CurMonth = CurMonthNum;
        }
        CurrentDate = CurDate.getDate() + "/" + CurMonthNum + "/" + CurDate.getYear();
        CurrentDate2 = CurDay + "/" + CurMonth + "/" + CurDate.getYear();
        if ((formobj.elements["DeclarationDate"].value == CurrentDate) || (formobj.elements["DeclarationDate"].value == CurrentDate2)) {
        }
        else{
           alertMsg += "\nThe date, " + formobj.elements["DeclarationDate"].value + ", in the declaration is not the current date or is not in the correct date format.  The current date is: " + CurrentDate2 + ".\n";
        }
    }

    if (formobj.elements["FirstNames"].value.length > 40) {
        alertMsgTwo += " - 1. Complainant: First names (max 40 characters)." + "\n";
    }
    if (formobj.elements["Surname"].value.length > 40) {
        alertMsgTwo += " - 1. Complainant: Surname (max 40 characters)." + "\n";
    }
    if (formobj.elements["ResAddress"].value.length > 200) {
        alertMsgTwo += " - 1. Complainant: Residential address (max 200 characters)." + "\n";
    }
    if (formobj.elements["ResSuburb"].value.length > 30) {
        alertMsgTwo += " - 1. Complainant: Residential suburb (max 30 characters)." + "\n";
    }
    if (formobj.elements["ResState"].value.length > 3) {
        alertMsgTwo += " - 1. Complainant: Residential state (max 3 characters)." + "\n";
    }
    if (formobj.elements["ResPostCode"].value.length > 4) {
        alertMsgTwo += " - 1. Complainant: Residential post code (max 4 characters)." + "\n";
    }   
    if (formobj.elements["PostAddress"].value.length > 200) {
        alertMsgTwo += " - 1. Complainant: Postal address (max 200 characters)." + "\n";
    }
    if (formobj.elements["PostSuburb"].value.length > 30) {
        alertMsgTwo += " - 1. Complainant: Postal suburb (max 30 characters)." + "\n";
    }
    if (formobj.elements["PostState"].value.length > 3) {
        alertMsgTwo += " - 1. Complainant: Postal state (max 3 characters)." + "\n";
    }
    if (formobj.elements["PostPostCode"].value.length > 4) {
        alertMsgTwo += " - 1. Complainant: Postal post code (max 4 characters)." + "\n";
    } 
    if (formobj.elements["PhoneDay"].value.length > 100) {
        alertMsgTwo += " - 1. Complainant: Telephone number (daytime) (max 100 characters)." + "\n";
    }
    if (formobj.elements["PhoneAH"].value.length > 100) {
        alertMsgTwo += " - 1. Complainant: Telephone number (after hours) (max 100 characters)." + "\n";
    }   
    if (formobj.elements["Mobile"].value.length > 100) {
        alertMsgTwo += " - 1. Complainant: Mobile phone number (max 100 characters)." + "\n";
    }
    if (formobj.elements["Fax"].value.length > 100) {
        alertMsgTwo += " - 1. Complainant: Fax number (max 100 characters)." + "\n";
    }     
    if (formobj.elements["Email"].value.length > 100) {
        alertMsgTwo += " - 1. Complainant: Email (max 100 characters)." + "\n";
    }  
    if (formobj.elements["Occupation"].value.length > 50) {
        alertMsgTwo += " - 1. Complainant: Occupation (max 50 characters)." + "\n";
    }  
    if (formobj.elements["RespFirstNames"].value.length > 40) {
        alertMsgTwo += " - 2. Respondent: First names (max 40 characters)." + "\n";
    }  
    if (formobj.elements["RespSurname"].value.length > 40) {
        alertMsgTwo += " - 2. Respondent: Surname (max 40 characters)." + "\n";
    }
    if (formobj.elements["FirmName"].value.length > 50) {
        alertMsgTwo += " - 2. Respondent: Firm name (max 50 characters)." + "\n";
    } 
    if (formobj.elements["FirmAddress"].value.length > 200) {
        alertMsgTwo += " - 2. Respondent: Firm address (max 200 characters)." + "\n";
    }  
    if (formobj.elements["FirmSuburb"].value.length > 30) {
        alertMsgTwo += " - 2. Respondent: Firm suburb (max 30 characters)." + "\n";
    } 
    if (formobj.elements["FirmState"].value.length > 3) {
        alertMsgTwo += " - 2. Respondent: Firm state (max 3 characters)." + "\n";
    } 
    if (formobj.elements["FirmPostCode"].value.length > 4) {
        alertMsgTwo += " - 2. Respondent: Firm post code (max 4 characters)." + "\n";
    } 
    if (formobj.elements["FirmPostalAddress"].value.length > 200) {
        alertMsgTwo += " - 2. Respondent: Firm postal address (max 200 characters)." + "\n";
    }  
    if (formobj.elements["FirmPostalSuburb"].value.length > 30) {
        alertMsgTwo += " - 2. Respondent: Firm postal suburb (max 30 characters)." + "\n";
    } 
    if (formobj.elements["FirmPostalState"].value.length > 3) {
        alertMsgTwo += " - 2. Respondent: Firm postal state (max 3 characters)." + "\n";
    } 
    if (formobj.elements["FirmPostalPostCode"].value.length > 4) {
        alertMsgTwo += " - 2. Respondent: Firm postal post code (max 4 characters)." + "\n";
    } 
    if (formobj.elements["RespPhoneDay"].value.length > 100) {
        alertMsgTwo += " - Q3: Telephone number (daytime) (max 100 characters)." + "\n";
    }
    if (formobj.elements["RespPhoneAH"].value.length > 100) {
        alertMsgTwo += " - 2. Respondent: Telephone number (after hours) (max 100 characters)." + "\n";
    }
    if (formobj.elements["RespMobile"].value.length > 100) {
        alertMsgTwo += " - 2. Respondent: Mobile phone number (max 100 characters)." + "\n";
    }
    if (formobj.elements["RespFax"].value.length > 100) {
        alertMsgTwo += " - 2. Respondent: Fax number (max 100 characters)." + "\n";
    }
    if (formobj.elements["RespEmail"].value.length > 100) {
        alertMsgTwo += " - 2. Respondent: Email (max 100 characters)." + "\n";
    }
    if (formobj.elements["ConductOccurred"].value.length > 50) {
        alertMsgTwo += " - 3. Complaint details: When did the conduct you are reporting occur? (max 50 characters)." + "\n";
    }
   
    if (alertMsgTwo.length == l_MsgTwo){
    }else{
        tmp = "\nPlease reduce the number of characters in the following fields:\n" + alertMsgTwo;
        alertMsgTwo = tmp;
        alertMsg += alertMsgTwo;
    }
    if (formobj.MakingComplaint[0].checked == true){
         formobj.elements["Purpose1"].value = "01"   
    }
    if (formobj.MakingComplaint[1].checked == true){
         formobj.elements["Purpose2"].value = "02"   
    }
    if (formobj.MakingComplaint[2].checked == true){
         formobj.elements["Purpose3"].value = "03"   
    }
    if (formobj.MakingComplaint[3].checked == true){
         formobj.elements["Purpose4"].value = "04"   
    }
    if (formobj.MakingComplaint[4].checked == true){
         formobj.elements["Purpose5"].value = "05"   
    }   
    if (formobj.MakingComplaint[5].checked == true){
         formobj.elements["Purpose6"].value = "06"   
    } 
        
    if (alertMsg.length == l_Msg){
        return true;
    }else{
        alert(alertMsg);
        alertMsg = "";
        return false;
    }
}