function validate(form) {

  // verify there is something in the name fields
  if(form.firstName.value == "") {
    alert("You need to insert your first name.");
    form.firstName.focus();
    return false;
  }

  if(form.lastName.value == "") {
    alert("You need to insert your last name.");
    form.lastName.focus();
    return false;
  }

// check the address fields
  if(form.streetAddress.value == "") {
    alert("You need to insert your street address.");
    form.streetAddress.focus();
    return false;
  }
  
  if(form.city.value == "") {
    alert("You need to insert your city.");
    form.city.focus();
    return false;
  }

// check zipCode field
  var zipStr =  form.zipCode.value;
  var zip = /^[0-9]{5}/;
  if( !zip.test(zipStr)) {
    alert("You need to insert a five digit zipcode.");
    form.zipCode.focus();
    return false;
  }

  // check phone number fields
  var threeDigits = /^[0-9]{3}/;
  var fourDigits = /^[0-9]{4}/;
  if( !threeDigits.test(form.phoneAreaCodeHome.value) ) {
    alert("You need a 3 digits in the area code of your phone number.");
    form.phoneAreaCodeHome.focus();
    return false;
  }
  if( !threeDigits.test(form.phonePrefixHome.value) ) {
    alert("You need a 3 digits in the prefix of your phone number.");
    form.phonePrefixHome.focus();
    return false;
  }
  if( !fourDigits.test(form.phoneLastFourHome.value) ) {
    alert("You need a 4 digits to complete your phone number.");
    form.phoneLastFourHome.focus();
    return false;
  }
  

// check the primary email field
// this will not catch all misformed email addresses, but will get most of them

  // setup the variables
  var field = form.emailAddressPrimary; // email field
  var str = field.value; // email string
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

  // test input against regular expressions
  if (  !reg2.test(str) | reg1.test(str) ) {
  alert("\"" + str + "\" is an invalid e-mail. Please check the address..."); // this is also optional
  field.focus();
  field.select();
  return false;

}
  
  // check membership type field
  if(form.membershipType.value == "") {
    alert("Please select a membership type.");
    return false;
  }
  
  // check username and password fields
  if(form.username.value == "") {
    alert("Please create a username.");
    form.username.focus();
    return false;
  }
    if(form.password.value == "") {
      alert("Please create a password.");
      form.password.focus();
      return false;
    }
document.application.buttonRegister.disabled=true;
  return true;
  
}
