var fault = "1";

function resetFault () {
 fault = "0";
}

function checkEmptybn (strng) {
 if (strng.length == 0) {
  fault = "1";
  document.reqform.bn.value = "Required Field";
 }
 else {
  return true;
 }
}

function checkEmptycn (strng) {
 if (strng.length == 0) {
  fault = "1";
  document.reqform.cn.value = "Required Field";
 }
 else {
  return true;
 }
}

function checkEmptypn (strng) {
 if (strng.length == 0) {
  fault = "1";
  document.reqform.pn.value = "Required Field";
 }
 else {
  return true;
 }
}

function checkEmail (strng) {
 if (strng == "") {
  fault = "1";
  document.reqform.em.value = "Required Field";
 }
 else {
  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(strng))) { 
   fault = "1";
   document.reqform.em.value = "Please enter a valid e-mail address!";
  }
  else { //test email for illegal characters
   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
   if (strng.match(illegalChars)) {
    fault = "1";
    document.reqform.em.value = "Your e-mail contains illegal characters!";
   }
   else {
    fault = "0";
    return true;
   }
  }
 }
}

function checkForm () {
 if (fault != "0" || 
     document.reqform.bn.value.length == 0 || 
     document.reqform.cn.value.length == 0 || 
     document.reqform.pn.value.length == 0 || 
     document.reqform.em.value.length == 0 || 
     document.reqform.bn.value == "Required Field" || 
     document.reqform.cn.value == "Required Field" || 
     document.reqform.pn.value == "Required Field" || 
     document.reqform.em.value == "Required Field" || 
     document.reqform.em.value == "Please enter a valid e-mail address!" || 
     document.reqform.em.value == "Your e-mail contains illegal characters!") {
  alert("Please make sure all fields are filled in correctly.");
  document.reqform.focus();
  document.reqform.select();
  return false;
 }
 else {
  document.reqform.submit();
  return true;
 }
}

