function SearchFormCheck() { if (document.searchform.strKeyword.value == "" || document.searchform.strKeyword.value == " " || document.searchform.strKeyword.value.length < 3) { alert("Please specify a search string of 3 letters or more."); return false; } else { return true; } } function validate(Form) { var AlertMsg = ""; var Error = 0; var Location1 = 0; var Location2 = 0; if (Form.Email.value > "") { //simple check for important email characters Location1 = Form.Email.value.indexOf('@'); Location2 = Form.Email.value.indexOf('.', Location1); if (Location1 == -1 || Location2 == -1) { AlertMsg = AlertMsg + "\n- Please enter an E-mail address in the format 'name@someplace.com'\n For example: 'jdoe@service.com'."; Form.Email.focus(); Form.Email.select(); Error = 1; } //simple check for any spaces if (Form.Email.value.indexOf (' ') > -1) { if (Error == 0) { AlertMsg = AlertMsg + ("\n- E-mail address cannot contain spaces.") ; Form.Email.focus(); Form.Email.select(); Error = 1; } } } else { AlertMsg = AlertMsg + "\n" + "- Please enter an E-Mail address."; Form.Email.focus(); Form.Email.select(); Error = 1; } if (Error == 1) { alert(AlertMsg); return false; } else { return true; } } function validateExecBenefits(Form1) { var Error = 0; var AlertMsg = ""; var Location1 = 0; var Location2 = 0; if (Form1.name.value == "" || Form1.name.value == null) { AlertMsg = AlertMsg + "\n" + "- Please enter your name."; Form1.name.focus(); Form1.name.select(); Error = 1; } if (Form1.ContactPref[0].checked == true) { if (Form1.EmailAddress.value == "" || Form1.EmailAddress.value == null) { AlertMsg = AlertMsg + "\n" + "- Please enter an E-Mail address."; Form1.EmailAddress.focus(); Form1.EmailAddress.select(); Error = 1; } else { // simple check for important email characters Location1 = Form1.EmailAddress.value.indexOf('@'); Location2 = Form1.EmailAddress.value.indexOf('.', Location1); if (Location1 == -1 || Location2 == -1) { AlertMsg = AlertMsg + "\n- Please enter an E-mail address in the format 'name@creditunion.org'\n For example: 'jdoe@abccu.org'."; Form1.EmailAddress.focus(); Form1.EmailAddress.select(); Error = 1; } // simple check for any spaces if (Form1.EmailAddress.value.indexOf (' ') > -1) { if (Error == 0) { AlertMsg = AlertMsg + ("\n- E-mail address cannot contain spaces.") ; Form1.EmailAddress.focus(); Form1.EmailAddress.select(); Error = 1; } } } } else { if (Form1.business_phone_num.value == "" || Form1.business_phone_num.value == null) { AlertMsg = AlertMsg + "\n" + "- Please enter your phone number."; Form1.business_phone_num.focus(); Form1.business_phone_num.select(); Error = 1; } } if (Error == 1) { alert(AlertMsg); return false; } else { return true; } } function OpenPopup(url, name, width, height) { var attrib = 'left=0,top=10,scrollbars,width=' + width + ',height=' + height; var thePopup = window.open(url,name,attrib); thePopup.focus(); } function OpenPopupWithParms(url, name, w, h, rs, sb, s, tb) { var winHeight = h; var winWidth = w; var attrib = "width=" + winWidth + ",height=" + winHeight + ",resizable=" + rs + ",scrollbars=" + sb + ",status=" + s + ",toolbar=" + tb var objCertWin; objCertWin = window.open(url, name, attrib); objCertWin.focus(); } function ClearForm(objForm) /*******************************************************************************/ /* Function: ClearForm */ /* */ /* Description: This function loops though all of the fields on a form */ /* and sets the value of all text fields to an empty */ /* string and the value of check boxes and radio buttons */ /* to unchecked. */ /* */ /* Inputs: A form */ /*******************************************************************************/ { var intElements = objForm.elements.length for (var i=0; i < intElements; i++) { switch (objForm.elements[i].type) { case "text": objForm.elements[i].value = ""; break; case "textarea": objForm.elements[i].value = ""; break; case "checkbox": objForm.elements[i].checked = false; break; case "radio": objForm.elements[i].checked = false; break; case "password": objForm.elements[i].value = ""; break; case "select-one": objForm.elements[i].selectedIndex = 0; break; default: }/* End Switch */ } /* End-For */ } /* End ClearForm() */ function CheckDate(objFormDate, blnBlankOk) /*******************************************************************************/ /* Function: CheckDate */ /* */ /* Description: This function validates a form field containing a */ /* date. If the date is not valid an error message */ /* is displayed and the focus is set to the invalid */ /* date field. */ /* */ /* Author: Brad Markham */ /* */ /* Date: 10/04/2001 */ /* */ /* Inputs: objFormDate - a form field containing a date */ /* blnBlankOk - indicates if a blank field is valid */ /* */ /* Returns: True for a valid date */ /* False for an invalid date */ /* */ /*******************************************************************************/ { var strDate = objFormDate.value; var objDate; strDate = strDate.trim(); if (ValidateDate(strDate, blnBlankOk)){ if (strDate != "" ){ /* Replace all '-' with '/' to create a validate Date object in Netscape */ strDate = strDate.replace(/-/g, "/"); objDate = new Date(strDate); /* Format date*/ objFormDate.value = FormatDate(objDate); return true; }else{ if (!blnBlankOk){ alert("Invalid date entered."); objFormDate.focus(); objFormDate.select(); return false; } /* End-If */ } /* End-If */ }else{ alert("Invalid date entered."); objFormDate.focus(); objFormDate.select(); return false; } /* End-If */ } /* End CheckDate() */ function ValidateDate(strDate, blnBlankOk) /*******************************************************************************/ /* Function: ValidateDate */ /* */ /* Description: This function validates a date string and returns */ /* true for a valid date and false for an invalid date. */ /* */ /* Author: Brad Markham */ /* */ /* Date: 10/04/2001 */ /* */ /* Inputs: strDate - a string containing a date */ /* blnBlankOk - indicates if an empty string is valid */ /* */ /* Returns: True for a valid date */ /* False for an invalid date */ /* */ /*******************************************************************************/ { var objRegExp = new RegExp("/|-", "g"); var strTmpDt = ""; var intDividerPos1 = -1; var intDividerPos2 = -1; var strMonth = ""; var intMonth = -1; var strDay = ""; var intDay = -1; var strYear = ""; var strInputDt = ""; var objDate; strDate = strDate.trim(); if (strDate == ""){ if (blnBlankOk == true){ return true; }else{ return false; } /* End-If */ } /* End-If */ /* Removes the dividers '/' and '-' */ strTmpDt = strDate.replace(objRegExp, ""); /* Verifies that remaining part of the date is numeric */ if (isNaN(strTmpDt)) { return false; } /* End-If */ /* Replace all '-' with '/' to make parsing easier */ strDate = strDate.replace(/-/g, "/"); /* Isolate Month */ intDividerPos1 = strDate.indexOf("/"); if (intDividerPos1 == -1) { return false; } /* End-If */ strMonth = strDate.substring(0,intDividerPos1); intMonth = parseInt(strMonth,10); /* Left-pad the month with a zero */ if(intMonth < 10) { strMonth = "0" + intMonth.toString(); } /* End-If */ /* Isolate Day */ intDividerPos2 = strDate.indexOf("/",intDividerPos1 + 1); if (intDividerPos2 == -1) { return false; } /* End-If */ strDay = strDate.substring(intDividerPos1 + 1,intDividerPos2); intDay = parseInt(strDay,10); /* Left-pad the day with a zero */ if(intDay < 10) { strDay = "0" + intDay.toString(); } /* End-If */ /* Isolate Year and build input date in the same style as FormatDate */ strYear = strDate.substr(intDividerPos2 + 1); strInputDt = strMonth + "/" + strDay + "/" + strYear; /* Compare original input date to the date returned from the Date object */ /* The Date object will fix some bad dates automatically, for instance */ /* if the date entered was 9/45/2001 the Date object would return 10/15/2001 */ /* This code flags those dates as invalid. */ objDate = new Date(strDate); if (FormatDate(objDate) != strInputDt){ return false; } /* End-If */ return true; } /* End ValidateDate()*/ function FormatDate(objDate) /*******************************************************************************/ /* Function: FormatDate */ /* */ /* Description: This function formats a date into MM/DD/YYYY */ /* */ /* Author: Brad Markham */ /* */ /* Date: 10/04/2001 */ /* */ /* Inputs: objDate - a valid date object */ /* */ /* Returns: A date string formatted as MM/DD/YYYY */ /* */ /*******************************************************************************/ { var intMonthNr; var aryMonth = new Array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'); var intDate; var strDate; var strFullDate; intMonthNr = objDate.getMonth(); intDate = objDate.getDate(); /* Left-pad the day with a zero */ if(intDate < 10) { strDate = "0" + intDate.toString(); }else{ strDate = intDate.toString(); } /* End-If */ strFullDate = aryMonth[intMonthNr] + "/" + strDate + "/" + objDate.getFullYear(); return strFullDate; } /* End FormatDate */ function TrimText(objFormField) /*******************************************************************************/ /* Function: TrimText */ /* */ /* Description: This function removes the leading and trailing spaces */ /* from a field on a form. */ /* */ /* Author: Brad Markham */ /* */ /* Date: 10/08/2001 */ /* */ /* Inputs: objFormField - A form element object */ /* */ /*******************************************************************************/ { var strText = objFormField.value; objFormField.value = strText.trim(); } /* End TrimText() */ /*******************************************************************************/ /* Creates the trim() function for the String object if it does not */ /* already exist. */ /*******************************************************************************/ if (typeof(String)!='undefined' && typeof(String.prototype)!='undefined'){ if (typeof(String.prototype.trim)=='undefined'){ function String_Trim() /*******************************************************************************/ /* Function: String_Trim */ /* */ /* Description: This function removes the leading and trailing spaces */ /* from the current String object. */ /* */ /* Author: Brad Markham */ /* */ /* Date: 10/08/2001 */ /* */ /*******************************************************************************/ { var strValue = this; /* Gets the current string */ /* Removed leading spaces */ while (strValue.search(/^ /) != -1) { strValue = strValue.replace(/^ /, ""); } /* End While */ /* Removed trailing spaces */ while (strValue.search(/ $/) != -1) { strValue = strValue.replace(/ $/, ""); } /* End While */ return(strValue); } /* End Trim() */ String.prototype.trim = String_Trim; } /* End-If */ } /* End-If */ function Currency(dblNumber) /*******************************************************************************/ /* Function: Currency */ /* */ /* Description: This function formats a number as currency. Adding a */ /* dollar sign and commas and rounding the number to */ /* two decimal places. */ /* */ /* Author: Brad Markham */ /* */ /* Date: 10/08/2001 */ /* */ /* Inputs: dblNumber - the number to be formatted */ /* */ /* Returns: strFormatNum - the string equivalent of the number */ /* formatted as currency ($9,999.00) */ /* */ /*******************************************************************************/ { var blnPositiveNum; var strNumber; var strDollars; var strCents; var strFormatNum; /* If the value is positive set blnPositiveNum = True */ blnPositiveNum = (dblNumber == Math.abs(dblNumber)); /* Get the absolute value of the number */ dblNumber = Math.abs(dblNumber); /* Round the number to the nearest cent */ dblNumber = dblNumber.toFixed(2); /* Convert the number to a string */ strNumber = dblNumber.toString(); /* Extract the dollars */ strDollars = strNumber.substring(0, strNumber.indexOf('.')); /* Extract the cents */ strCents = strNumber.substr(strNumber.indexOf('.') + 1); /* Walk backwards by 3 through the number and insert commas */ for (var i = strDollars.length - 3; i > 0; i=i-3) strDollars = strDollars.substring(0,i) + ',' + strDollars.substring(i,strDollars.length); /* put it all together and return it */ strFormatNum = ((blnPositiveNum)?'':'-') + '$' + strDollars + '.' + strCents return (strFormatNum); } /* End Currency() */ /*******************************************************************************/ /* Creates the toFixed() function for the Number object if it does not */ /* already exist. */ /*******************************************************************************/ if (typeof(Number)!='undefined' && typeof(Number.prototype)!='undefined'){ if (typeof(Number.prototype.toFixed)=='undefined'){ function Number_toFixed(intPrecision) /*******************************************************************************/ /* Function: Number_toFixed */ /* */ /* Description: This function will round a number to given number of */ /* decimal places. */ /* */ /* Author: Brad Markham */ /* */ /* Date: 09/13/2001 */ /* */ /* Inputs: intPrecision - The number of decimal places to round */ /* the number to. */ /*******************************************************************************/ { var dblNum = this; /* Gets the current number */ var intTmp; var dblFixedNum; /* Default decimal places to 2 if not passed in */ if (typeof(intPrecision) == 'undefined') intPrecision = 2; /* Round number to precision requested */ intTmp = Math.pow(10, intPrecision); dblNum = Math.round(dblNum * intTmp) / intTmp; /* Ensure the number has one decimal place, so the indexOf function works */ dblNum += Math.pow(10, - (intPrecision + 1)); /* Convert the number to a string */ dblNum = dblNum.toString(); if (intPrecision == 0) { dblFixedNum = dblNum.substring(0, dblNum.indexOf('.')) }else{ dblFixedNum = dblNum.substring(0, dblNum.indexOf('.') + intPrecision + 1) } /* End-If */ return dblFixedNum; } /* End Number_toFixed() */ Number.prototype.toFixed = Number_toFixed; } /* End-If */ } /* End-If */