var digits = "0123456789"; var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz" var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" var whitespace = " \t\n\r"; var defaultEmptyOK = false var decimalPointDelimiter = "." function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isWhitespace (s) { var i; if (isEmpty(s)) return true; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false; } return true; } function isDigit (c) { return ((c >= "0") && (c <= "9")) } function isInteger (s) { var i; if (isEmpty(s)) if (isInteger.arguments.length == 1) return defaultEmptyOK; else return (isInteger.arguments[1] == true); for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (!isDigit(c)) return false; } return true; } function isFloat (s) { var i; var seenDecimalPoint = false; if (isEmpty(s)) if (isFloat.arguments.length == 1) return defaultEmptyOK; else return (isFloat.arguments[1] == true); if (s == decimalPointDelimiter) return false; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true; else if (!isDigit(c)) return false; } return true; } function warnInvalid (theField, s) { theField.focus() theField.select() alert(s) return false } function warnMsg (theField, s) { theField.focus() alert(s) return false } // ============================= function checkEmptyString (theField, s) { if (isWhitespace(theField.value)) return warnInvalid (theField, s); else return true; } function checkInteger (theField, s) { if (!isInteger(theField.value)) return warnInvalid (theField, s); else return true; } function checkFloat(theField, s) { if (!isFloat(theField.value)) return warnInvalid (theField, s); else return true; } function getListBoxIndex(lstbox) { var j=-1 for (var i = 0; i < lstbox.length; i++) { if (lstbox.options[i].selected == true ) { j=i; break } } return j } function getListBoxValue(lstbox) { var s="" for (var i = 0; i < lstbox.length; i++) { if (lstbox.options[i].selected == true ) { s= lstbox.options[i].value; break } } return s } function isListBoxSelected(lstbox) { var j=-1 for (var i = 0; i < lstbox.length; i++) { if (lstbox.options[i].selected == true ) { j=i return true } } return false } function checkListBoxSelected(lstbox,s) { if (isListBoxSelected(lstbox) == false) return warnMsg (lstbox, s); else return true; } function checkEmptyListBox(lstbox,s) { if (getListBoxValue(lstbox) == "") return warnMsg (lstbox, s); else return true; } function checkZero(theField, s) { if (theField.value == 0) return warnInvalid (theField, s); else return true; } function checkMaxiValue(theField, iValue, s) { if (theField.value > iValue ) return warnInvalid (theField, s); else return true; } function alltrim(inputString) { if (typeof inputString != "string") { return inputString; } var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); } while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; } function SelectListBoxItem(lstbox,s) { for (var i = 0; i < lstbox.length; i++) { if (alltrim(lstbox.options[i].value) == s ) { lstbox.options[i].selected = true ; break } } return i } function SelectListBoxItemByText(lstbox,s) { for (var i = 0; i < lstbox.length; i++) { if (alltrim(lstbox.options[i].text) == s ) { lstbox.options[i].selected = true ; break } } return i }