///////////////////////////////////////////// // This file contains generic // javascript functions for // form processesing and validation // // Author: JVS // Date : 09/20/01 // ///////////////////////////////////////////// /////////////////////////////////////////////// //Reset the Form /////////////////////////////////////////////// function resetForm(myForm) { myForm.reset(); }//end resetForm /////////////////////////////////////////////// // Returns the value selected in a select object /////////////////////////////////////////////// function getSelectValue(selectObject) { //BCOMPAT //ie runtime errors if you access a options array slot //smaller then the array, so if nothing is selected //just return false now, netscape returns false in that case if(selectObject.selectedIndex < 0){ return false; }//end if return selectObject.options[selectObject.selectedIndex].value; }// end getSelectValue /////////////////////////////////////////////// // Returns delimited string of values in multipe // selected in a select object /////////////////////////////////////////////// function getMultipleSelectValue(selectObject,delimiter) { var results = ""; for (var j=selectObject.length -1;j>=0;j--){ if (selectObject.options[j].selected == true) { results += selectObject.options[j].value + delimiter; }//end if }//end for select obj if (results.length > 0) { return results.substring(0,results.length-1); } else { return false; } }// end getMultipleSelectValue /////////////////////////////////////////////// // Sets the value selected in a select object /////////////////////////////////////////////// function setSelectValue(selectObject,value) { var j; for(j=0;j "9") { if( ch != "." && ch != "-") return false; }//end if } //end for return true; }//end IsAllDigits /////////////////////////////////////// // clears all non number chars // in the string ////////////////////////////////////// function makeAllDigits(string) { var notDigits = /\D/gi;//not any number of digits var newString = string.replace(notDigits,"") return newString; }//end IsAllDigits /////////////////////////////////////// // setDaysInMonth // expects month day and year select objects // the month and year selects should call // this on change // it controls the number of days in the day // select so that invalid dates cannot be selected // //pass in true to blankFlag if the first option in //the selects is blank, or says (please select) or something ////////////////////////////////////// function setDaysInMonth(month,day,year,blankFlag) { var lastDayOfMonth = daysInMonth(getSelectValue(month), getSelectValue(day), getSelectValue(year)); var j; for (j=1;j<=31;j++) { if (j > lastDayOfMonth) { if (! blankFlag) { day.options [j-1].text="--"; day.options [j-1].value=""; } else { day.options [j].text="--"; day.options [j].value=""; } } else { if (! blankFlag) { day.options [j-1].text=j; day.options [j-1].value=j; } else { day.options [j].text=j; day.options [j].value=j; } } }//end for }//end setDaysInMonth //////////////////////////////////// //returns number of days in month /////////////////////////////////// function daysInMonth(month, day, year) //returns number of days on month { month = Number(month); year = Number(year); day = Number(day); if (month==2) { //February if (year == Math.round(year / 4) * 4) //leap year { return 29; } else { //non-leap year return 28; }//end if } else if (month==4) { //April return 30; } else if (month==6) { //June return 30; } else if (month==9) { //September return 30; } else if (month==11) { //November return 30; } else { return 31; }//end if }// end daysInMonth //////////////////////////////////// //these two are realted to the date active flag issue... /////////////////////////////////// //sets dateActive to true onChange date element function activateDate(form) { form.dateActive.value = "true"; }//end activateDate //sets dateActive to false on form reset function resetDate(form) { form.dateActive.value = "false"; }//end resetDate //////////////////////////////////// //function allHaveValues //accepts any number of form objects and //returns true if they ALL have values //accepts text, checkbox, select, select multiple, //textarea, password and hidden objs /////////////////////////////////// function allHaveValues(){ var j; for(j=0;j