function csRule1(objField, strTextLabel) { var strReturn =''; if (objField.value == "") { strReturn = "Your " + strTextLabel + " is required"; } return strReturn; } function csValidate(objField,strTextLabel,strRules) { var a = new Array(); var i = 0; var strAlertMessage=''; var strTemp = new String(); var strReturn=''; strTemp = strRules; a = strTemp.split('|'); for (i = 0; i < a.length ;i++) { switch(a[i]) { case '1':strReturn =csRule1(objField, strTextLabel); if (strReturn != '') { strAlertMessage += strReturn + '\n'; } break; default:break; } } return strAlertMessage; } function csValidateALL(f) { var strAlertMessage=''; strAlertMessage += csValidate(f.name,'name','1'); strAlertMessage += csValidate(f.address,'Address','0'); strAlertMessage += csValidate(f.city,'City','0'); strAlertMessage += csValidate(f.state,'State','0'); strAlertMessage += csValidate(f.zip,'Zip','0'); strAlertMessage += csValidate(f.email,'e-mail','1'); strAlertMessage += csValidate(f.question,'Question','0'); if (strAlertMessage != '') { alert(strAlertMessage); return false; } }