// form validation
function ValidateForm(frmFormName) {

  var name = frmFormName.txtName.value;
  var email = frmFormName.txtEmail.value;
  var phone = frmFormName.txtPhone.value;
  var date = frmFormName.txtDate.value;
  var enquiry = frmFormName.cboEnquiry.value;
  var questions = frmFormName.txtQuestions.value;
    
  var msg = '';

  //check the name
  if (name == '') {
    msg += '\tName.\n'
  }
  
  //check the email
  if (email  == '') {
    msg += '\tEmail.\n';
  } else {
    //check valid email address
    var emailRegEx = /^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/;

    if (!emailRegEx.test(email)) {
      msg += '\tInvalid Email Address.\n'
    }
  }
  
  //check for default date text
  if (date != 'dd/mm/yyyy') {
    //check the date only if there is one entered
    var dateRegEx = /(0[1-9]|[12][0-9]|3[01])[/]((0)?[1-9]|1[012])[/](20)\d\d/;
  
    if (!dateRegEx.test(date)) {
      msg += '\tInvalid date.\n';
    }
  }

  if (msg != '') {
      alert('Please complete the following:\n' + msg);
	  return false;
  }
  
  return true;
}
