<!--
/* *************************************************************
Form Validation script
Use » characters as first character in field names
Checks text box, textarea, drop-down, checkbox and radio fields
**************************************************************** */

<!--
/* *************************************************************
Form Validation script
Use tilde ~ character as first character in field names
DO NOT USE the » character
Checks text box, textarea, drop-down, checkbox and radio fields
**************************************************************** */


function Reset(){
return confirmIt = confirm("Are you sure you want to reset the form?")
}	


function checkFields(){

var theform = document.forms[0]

for(i=0; i<theform.elements.length; i++){
     var field = theform.elements[i]
     var isReq = (field.name.charAt(0)=="~") ? true : false
     if(isReq){
     	if((field.type=="text" || field.type=="textarea" || field.type=="password") && field.value==""){
     	alert("Please fill in the '"+field.name+ "' field.")
     	setTimeout("document.forms[0].elements["+i+"].focus()", 0)
     	return false
     	}
     	else if(field.type=="select-one" && field.selectedIndex == 0){	
     	alert("Please select a value for the '"+field.name+ "' field.")
     	setTimeout("document.forms[0].elements["+i+"].focus()", 0)
     	return false
     	}
     	else if(field.type=="select-multiple"){	
     	Sel=0
          for(o=0; o<field.options.length; o++){
          	if(field.options[o].selected){
          	Sel++
          	break
          	}
          }
          if(Sel == 0){
          alert("Please select a value for the '"+field.name+ "' field.")
          setTimeout("document.forms[0].elements["+i+"].focus()", 0)
          return false
          }     	
     	}
     	else if(field.type=="radio" || field.type=="checkbox"){
     	var startingIndex = i	
     	var Checked = 0
     	var rLength=1
          while(field.name == theform.elements[i+1].name){
          rLength++
          i++ 
          }
          
          for(g = startingIndex; g < rLength+startingIndex; g++){
          	if(theform.elements[g].checked){
          	Checked++
          	break
          	}
          }     
          if(Checked == 0){
          alert("Please select a value for the '"+field.name+ "' "+field.type+" group")          
          setTimeout("document.forms[0].elements["+i+"].focus()", 0)
          return false
          }
     	}
     }//isReq
	  
	}//for
	return true
}
	
