function req(contactField, contactLabel) {
<!-- Check for non-blank field -->
  var result = true;
  if (contactField.value == "") {
    alert('Please enter a value for the "' + contactLabel +'" field.');
    contactField.focus();
    result = false;
  }
  return result;
}

function isInt (contactField, contactLabel) {
<!-- Check if zipcode is an integer and is longer than 5 numbers -->
  var result = true;
  if (!req(contactField, contactLabel))
    result = false;
  if (result) {
    var num = parseInt(contactField.value, 10);

	var longenough = (String(num).length >= 5);
    if (isNaN(num) || !longenough) {
      alert('Please enter valid number in the "' + contactLabel +'" field.');
      contactField.focus();
	  contactField.value = "";
      result = false;
    }
  }
  return result;
}

function validEmail(contactField, contactLabel) {
<!-- Check for "valid" email (not empty, has "@" sign and ".") -->
  var result = false;
  if (req(contactField, contactLabel))
    result = true; <!-- email field is not empty -->
  if (result) {
    var tempstr = new String(contactField.value);
    var aindex = tempstr.indexOf("@");
    if (aindex > 0) {  <!-- "@" sign was found, now check for "." -->
      var pindex = tempstr.indexOf(".",aindex);
      if ((pindex > aindex+1) && (tempstr.length > pindex+1)) {
        result = true;  <!-- "." was found, assume valid email -->
      } 
	  else {
        result = false;  <!-- no "." found in email address -->
      }
	}
	else {
	  result = false;  <!-- no "@" sign found in email address -->
    }
  }
  if (!result) {
    alert("Please enter a valid email address " + "in the form: yourname@yourdomain.com");
    contactField.focus();
  }
  return result;
}

function valform (validateform) {
<!-- Validate form fields as specified below -->
<!-- Validate name -->
  if (!req(validateform.name, "Name")) {
     return false;
  }
  <!-- Validate zip -->
  if (!isInt(validateform.zip, "Zip")) {
    return false;
  }
  <!-- Valid email -->
  if (!validEmail(validateform.email, "Email")) {
    return false;
  }
  return true;
}