Subject: RE: Javascript Validation Help
Here is my entire validation code. Please note that, if I remove the proposed new code, no errors occur.
//****************************
function validate() {
errMSG = “”
var f = document.forms[0];
if(f.JobDateEstStart.value == ‘’) {
if (errMSG != “”) {
errMSG+="\nEnter the Estimated Start Date";
}else {
errMSG+="Please correct the following:\n\nEnter the Estimated Start Date\n";
}
}
if(f.RSSqrs.value == ‘’) {
if (errMSG!=“”) {
errMSG+="Enter the Total Squares\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Total Squares\n";
}
}
if(f.JobGuaranteeType.selectedIndex<1){
if (errMSG!=“”) {
errMSG += "Select a Guarantee Type\n";
}else {
errMSG+="Please correct the following:\n\nSelect a Guarantee Type\n";
}
}
if(f.JobGuaranteeDuration.selectedIndex<1){
if (errMSG!=“”) {
errMSG += "Select a Guarantee Duration\n";
}else {
errMSG+="Please correct the following:\n\nSelect a Guarantee Duration\n";
}
}
if(f.JobName.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Project Name\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Project Name\n";
}
}
if(f.JobSiteAddress.value ==‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Job Site Address\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Job Site Address\n";
}
}
if(f.JobSiteCity.value ==‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Job Site City\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Job Site City\n";
}
}
if(f.JobSiteState.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Job Site State\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Job Site State\n";
}
}
if(f.JobSiteZip.value ==‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Job Site Zip\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Job Site Zip\n";
}
}
if(f.JobSiteBldgUse.selectedIndex < 1){
if (errMSG!=“”) {
errMSG += "Select the Building Use\n";
}else {
errMSG+="Please correct the following:\n\nSelect the Building Use\n";
}
}
if(f.JobBldgOwnerName.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Building Owner Name\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Building Owner Name\n";
}
}
if(f.JobOwnerAddress.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Building Owner Address\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Building Owner Address\n";
}
}
if(f.JobOwnerCity.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Building Owner City\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Building Owner City\n";
}
}
if(f.JobOwnerState.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Building Owner State\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Building Owner State\n";
}
}
if(f.JobOwnerZip.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Building Owner Zip\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Building Owner Zip\n";
}
}
if(f.JobRoofContractor.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Roofing Contractor Name\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roofing Contractor Name\n";
}
}
if(f.JobRFAddress.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Roofing Contractor Address\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roofing Contractor Address\n";
}
}
if(f.JobRFCity.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Roofing Contractor City\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roofing Contractor City\n";
}
}
if(f.JobRFState.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Roofing Contractor State\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roofing Contractor State\n";
}
}
if(f.JobRFZip.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Roofing Contractor Zip\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roofing Contractor Zip\n";
}
}
if(f.JobRFContactName.value == ‘’) {
if (errMSG!=“”) {
errMSG += "Enter the Roofing Contractor Contact\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roofing Contractor Contact\n";
}
}
//BEGINNING OF NEW CODE
var chkd = false;
for (counter = 0; counter < f.JobNoTechDoc.length; counter++){
if (f.JobNoTechDoc[counter].checked){
chkd = true;
}
}
if(chkd != false){
if(f.RSFamily1.selectedIndex < 1){
if (errMSG!="") {
errMSG += "Enter the Siplast Membrane System\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Siplast Membrane System\n";
}
}
if(f.RSProjectType1.selectedIndex < 1){
if (errMSG!="") {
errMSG += "Enter the Project Type\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Project Type\n";
}
}
if(f.RSBasePly1.selectedIndex < 1){
if (errMSG!="") {
errMSG += "Enter the Base Ply for the Siplast Roof System\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Base Ply for the Siplast Roof System\n";
}
}
if(f.RSFinishPly1.selectedIndex < 1){
if (errMSG!="") {
errMSG += "Enter the Finish Ply for the Siplast Roof System\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Finish Ply for the Siplast Roof System\n";
}
}
if(f.RSRoofDkType1.selectedIndex < 1){
if (errMSG!="") {
errMSG += "Enter the Roof Deck Type\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Roof Deck Type\n";
}
}
if(f.RSRoofDkSlope1.selectedIndex < 1){
if (errMSG!="") {
errMSG += "Enter the Slope per Foot\n";
}else {
errMSG+="Please correct the following:\n\nEnter the Slope per Foot\n";
}
}
}else{
if (errMSG!="") {
errMSG += "Enter the # of Roof Constructions\n";
}else {
errMSG+="Please correct the following:\n\nEnter the # of Roof Constructions\n";
}
}
//END OF NEW CODE
if (errMSG != “”) {
alert(errMSG);
f.SaveOptions.value = ‘0’;
return false
}
f.SaveOptions.value = ‘1’;
return true
}
//****************************