function validator() { this.inputName = new Array(); this.validationType = new Array(); this.formName = new Array(); this.errorMessage = new Array(); this.formSubmitObject = ""; this.length = 0; this.emptyErrorMessage = "The required field is missing: "; this.showError = true; this.validate = validate; this.required = required; this.unrequired = unrequired; this.isInputValid = isInputValid; this.displayError = displayError; this.isEmailValid = isEmailValid; this.isFileValid = isFileValid; this.isCCExpValid = isCCExpValid; this.isCCNumValid = isCCNumValid; this.isMinChecked = isMinChecked; this.isPassWordValid = isPassWordValid; this.isPhoneValid = isPhoneValid; this.isZipValid = isZipValid; this.getIndex = getIndex; } function setFormSubmitObject(formName) { this.formSubmitObject= eval("document."+formName); } function getFormObject(formNameTemp) { if(typeof inputNameTemp == 'string') { formName = eval("document."+formNameTemp); }else{ formName = formNameTemp; } return formName; } function getInputObject(formNameTemp,inputNameTemp) { if((typeof formNameTemp == 'string') && (typeof inputNameTemp == 'string') ) { inputName = eval("document."+formNameTemp+"."+inputNameTemp); }else if(typeof inputNameTemp == 'string'){ formName = getFormObject(formNameTemp); inputName = formName[inputNameTemp]; }else{ inputName = inputNameTemp; } return inputName; } /* function setErrorMessage(inputNameTemp,message) { for(i=0;i= 0 ) { this.validationType[ index ] = "NONE"; } } function displayError(formName,inputName,errorType) { if(this.showError==false) return; index = this.getIndex( formName,inputName ); if ( index >= 0 ) { if ( this.errorMessage[ index ] != null ) { alert( this.errorMessage[index] ); return; } } if(errorType=="EMPTY") { alert(this.emptyErrorMessage+' '+inputName); } } function isInputValid(formNameTmp,inputName,validationType) { formName = getFormObject(formNameTmp); elementName = getInputObject(formNameTmp,inputName); if ( ! formName ) { alert( "Error getting Form: " + formNameTmp ); return false; } if ( ! elementName ) { alert( "Error getting Element: " + inputName ); return false; } if ( (elementName.type == "text") || (elementName.type == "textarea") || (elementName.type == "hidden") || elementName.type == "password" ) { if(elementName.value=='') { this.displayError(formNameTmp,elementName.name,"EMPTY"); elementName.focus(); return false; } } else if(elementName.type=='select-one'|| elementName.type=='select') { index=elementName.selectedIndex; if(index==-1 || elementName.options[index].value == "") { this.displayError(formNameTmp,elementName.name,"EMPTY"); elementName.focus(); return false; } } else if(elementName.type=='checkbox') { if(elementName.checked==false) { this.displayError(formNameTmp,inputName,"EMPTY"); return false; } } else if( elementName[0].type=='radio') { var r; for ( r = 0; r < elementName.length; ++r ) { if(elementName[r].checked == true ) { return true; } } this.displayError(formNameTmp,inputName,"EMPTY"); return false; } else if(elementName.type==null) { radioLength=elementName.length; if(!(radioLength>0)) { //alert('element not defined'); return false; } for(j=0;j thisyear ) { return true; } else if ( sel_year < thisyear ) { cc_mon.focus(); return false; } if ( sel_month < thismonth ) { cc_mon.focus(); return false; } return true; } function isPassWordValid(formName,pwd1Temp,pwd2Temp) { pwd1=getInputObject(formName,pwd1Temp).value; pwd2=getInputObject(formName,pwd2Temp).value; //the modify_user form does not require passwords unless they are being changed if(formName=='user_modify' && pwd1 == "" && pwd2=="") return true; if(!(pwd1==pwd2)) { alert("The password you provided does not match the confirmation password. Please try again!"); return false; } if(pwd1.length < 4 || pwd2.length < 4) { alert("Passwords must be 4 to 8 characters long. Please try again!"); return false; } if(pwd1.length > 8 || pwd2.length > 8) { alert("Passwords must be 4 to 8 characters long. Please try again!"); return false; } return true; } theValidator = new validator();