/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: wsabstract.com | http://www.wsabstract.com */
/* fields whose name is preceded by "required" are checked */
function checkrequired(which) {
  var pass=true;
  for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if (tempobj.name.substring(0,8)=="required") {
      if (((tempobj.type=="text"||tempobj.type=="textarea")&&
          tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
          tempobj.selectedIndex==0)) {
        pass=false;
        break;
      }
    }
  }
/* code in each field's index (in the HTML form) */
statefield=21;
zipcodefield=22;
emailaddress=25;
secondemailaddress=26;
captchafield=29;
txt=which.elements[emailaddress].value;
if ((txt=="")||(txt==null)) {
alert("Please enter a valid email address!");
return false;
}
txt1=which.elements[secondemailaddress].value;
if (!(txt1==txt)) {
alert(txt+"/"+txt1+"The email address fields do not match.");
return false;
}
txt=which.elements[emailaddress].value;
if (txt.indexOf("@")<3){
alert("Your email address seems wrong. Please"
+" check the email ID and '@' sign.");
return false;
}
if (txt.indexOf(".")<3){
alert("Your email address seems wrong. It should include "
+"a period symbol.")
return false;
}
txt=which.elements[statefield].value;
if (txt == 0)
{
alert("The first \"State\" option is not a valid selection.  Please choose one of the other options.");
return false;
}
txt=which.elements[captchafield].value;
if(!txt.match(/^\d{5}$/)) {
alert('Please enter the correct five digits in the box provided at the bottom of the form.');
which.elements[captchafield].focus();
return false; }


  if (!pass) {
    shortFieldName=tempobj.name.substring(8,30).toUpperCase();
    alert("The "+shortFieldName+" field is a required field.");
    return false;
  } else {
return true;
  }

}
