//-- JEO Productions  --  Feb 2002 --// Form processing and validation Javascript functions // = D E B U G =// = = = = = = = //var debugOn = true;var debugOn = false; function debugMsg(debMsg) {    if( debugOn ) {       if( !(debMsg==null || debMsg=="") ) {    // send debug message          alert(debMsg);        }    } }//===============================================(:=)// = F O R M   S T U F F =// = = = = = = = = = = = /* help_btn validateSubmit_btn   state_list pracType_list   pracName_txt email_txt fax_txt phone_txt contactName_txt  address_txt  zip_txt country_txt town_txt   persStatement_txt   websiteURL_txt  emailSubject_txt  imageURL_txt  */ // define types of validations to be performed const text_valid_type=1; const zip_valid_type=2; const phone_valid_type=3; const email_valid_type=4; const url_valid_type=5; const list_valid_type=6; const missionStatement_valid_type=7; const checkbox_valid_type=8;  const NO_URL_TYPE = 10; /* used with  function checkFieldValid(element, validateType, errMsg) return checkFieldValid(this, text_valid_type, "someErrText");return checkFieldValid(this, zip_valid_type, "someErrText");return checkFieldValid(this, phone_valid_type, "someErrText");return checkFieldValid(this, email_valid_type, "someErrText");return checkFieldValid(this, url_valid_type, "someErrText");return checkFieldValid(this, list_valid_type, "someErrText");return checkStatement( persStatement_txt ); */ function validateForm(theForm) { // check for practice type and name// pracType_list    debugMsg("In validateForm()");     /*// check contact information email_txt fax_txt phone_txt contactName_txt  address_txt  town_txt state_list zip_txt    country_txt  */   if( !checkFieldValid(theForm.pracName_txt, text_valid_type, "Enter a Name for your Practice/Business.") ) {      return false;   }   if( !checkFieldValid(theForm.email_txt, text_valid_type, "What is your email address?") ) {      return false;   }   if( !checkFieldValid(theForm.phone_txt, text_valid_type, "Enter a contact phone number.") ) {      return false;   }   if( !checkFieldValid(theForm.zip_txt, text_valid_type, "Enter your zip code.") ) {      return false;   }   if( !checkFieldValid(theForm.persStatement_txt, NO_URL_TYPE, "No URLs allowed in the PRACTICE DESCRIPTION - Personal Statement text box - possible SPAM.") ) {      return false;   }   missionFeedbackText = "Please enter up to 40 words of text describing you and what you have to offer. What makes you unique? What is your personal passion?";   if( !checkStatement(theForm.persStatement_txt, missionStatement_valid_type, "(Please keep to under 40 words)", missionFeedbackText) ) {      return false;   } /*// check personal statement entered persStatement_txt  */  defaltStatement = "(Please keep to under 40 words)";   if( !checkFieldValid(theForm.persStatement_txt, text_valid_type, "Enter a personal mission statement or some thoughts.") ) {         return false;   } else  if( theForm.persStatement_txt == defaltStatement ) {         return false;   }  /*// check for website, image URLS and email subject line to use websiteURL_txt  emailSubject_txt  imageURL_txt */   	// Now check to see if the agreements checks have been checked// 	alert("num checks found = " +theForm.agreement.length); 	var agreementChecked = true; 	for(i=0; i<theForm.agreement.length; i++) { 		if( (eval("document.signup_form.agreement[" + i + "].checked") != true) ) { 			 			agreementChecked = false; 		} 	} 	if(agreementChecked==false) { 		alert("You must check the agreements checkboxs before your entry is submitted.\r\n\r\nPlease close this window and then scroll down to the \"fine print\" section and check each box, indicating your agreement."); 		document.signup_form.agreement[0].focus; 		return false; 	} // if everything passes, return true valid-flag    return true;  }//===============================================(:=)  function isEmpty(entryTxt) {   if( entryTxt==null || entryTxt=="") return true;   else return false;  }//===============================================(:=) function isPosInteger(entryTxt) {//    entryStr = String(entryTxt);    for( var charloc=0; charloc<entryTxt.length; charloc++) {       var theChar = charAt(charloc);       if( theChar<"0" || theChar>"9" ) return false;    }   return true;  }//===============================================(:=) function checkStatement(element, validateType, initialFieldText, errMsg) {  debugMsg("In checkStatement()");          feedback = "\n\n" + errMsg;    isValid = false;    if( isEmpty(element.value) ) {       feedback = "The text you entered was invalid or blank.\n\n" + feedback;    }     else if( element.value == initialFieldText ) {       feedback = "Please erase text and add your own.\n\n" + feedback;    }     else isValid = true;    if( isValid ) {  debugMsg("return Valid()");                  return true;    } else {             element.focus();  debugMsg("return in-Valid()");                  alert(feedback);             return false;    }  }//===============================================(:=) function checkFieldValid(element, validateType, errMsg) {//    isValid = (element.value=="") ? 0 : 1;        feedback = "\n\n" + errMsg;        isValid = false;    switch (validateType) {       case 1: 		// var text_valid_type=1;  debugMsg("In checkFieldValid()");               if( isEmpty(element.value) ) {             feedback = "The text you entered was invalid or blank.\n\n" + feedback;          }           else isValid = true;          break;                 case 7:  //  missionStatement_valid_type  debugMsg("In checkFieldValid()");               if( isEmpty(element.value) || !checkFieldValid(element, NO_URL_TYPE) ) {             feedback = "The text you entered was invalid or blank." + feedback;          }           else isValid = true;          break;                            case 8:  //   var checkbox_valid_type=8;  debugMsg("In checkFieldValid()");               if( isEmpty(element.value) ) {             feedback = "You forgot to check a required checkbox." + feedback;          }           else isValid = true;          break;                 case NO_URL_TYPE:  //   check for spammers inserting urls where they should not  debugMsg("In checkFieldValid(NO_URL_TYPE)");               if (new String(element.value).search("http://") != -1)    {             feedback = "URLs are NOT allowed in this text box. Are you trying to spam us or entering a valid reference?" + feedback;          }           else isValid = true;          break;                default:             feedback = "Unknown type of validation object encountered." + feedback;          break;    }     if( isValid ) {  debugMsg("return Valid()");                  return true;    } else {             element.focus();  debugMsg("return in-Valid()");                  alert(feedback);             return false;    }   }//===============================================(:=) function validateSignupForm(theForm) {  debugMsg("in validateSignupForm()");         return checkFieldValid(theForm.pracName_txt, text_valid_type, "Please enter the Name of your Practice or Organization.");  } //===============================================(:=)