var vValidationDelim = "_YY_"; //vValidationDelim = "_YY_"; //vDisallowedCharacters = Array('"','\\'); var vValidateDebug=0; //-------------------------------------------------------------------------------------------------- /** * This function parses the hidden validation fields and tests the input values against them. * @param Form pFormObj The Form object to be validated * @return boolean False if any validation errors occur; true otherwise */ function fValidate (pFormObj) { if (vValidateDebug) { alert('fValidate('+pFormObj+')'); } var lvElements = pFormObj.elements; var i; for (i=0; i -1) { return fValidationError(pInput, 'The ' + lvChar + ' character is not allowed'); } } return true; } //-------------------------------------------------------------------------------------------------- /** * Tests the value of an "INT" input field and calls fValidationError if necessary * @param Input pInput The Input object to be tested * @param number pMin The minimum allowed value * @param number pMax The maximum allowed value * @return boolean False if an error occurs, true otherwise */ function fValidateInt (pInput, pMin, pMax) { if (vValidateDebug) { alert('fValidateInt('+pInput+', '+pMin+', '+pMax+')'); } if (pInput.value == '') { return true; } // Blank values pass if (parseInt(pInput.value,10) != pInput.value) { return fValidationError(pInput, 'Please enter an integer value'); } pInput.value = eval(pInput.value); return fValidateRange(pInput, pMin, pMax, 'an integer'); } //-------------------------------------------------------------------------------------------------- /** * Tests the value of a "DEC" input field and calls fValidationError if necessary * @param Input pInput The Input object to be tested * @param number pMin The minimum allowed value * @param number pMax The maximum allowed value * @return boolean False if an error occurs, true otherwise */ function fValidateDecimal (pInput, pMin, pMax) { if (vValidateDebug) { alert('fValidateDecimal('+pInput+', '+pMin+', '+pMax+')'); } if (pInput.value == '') { return true; } // Blank values pass if (parseFloat(pInput.value) != pInput.value) { return fValidationError(pInput, 'Please enter a numeric value'); } pInput.value = eval(pInput.value); return fValidateRange(pInput, pMin, pMax, 'a number'); } //-------------------------------------------------------------------------------------------------- /** * Tests the value of a numeric input field against a value range and calls fValidationError if necessary * @param Input pInput The Input object to be tested * @param number pMin The minimum allowed value * @param number pMax The maximum allowed value * @param string pTypeString A "pretty" data type ("an integer", "a number", etc.) for the error message * @return boolean False if an error occurs, true otherwise */ function fValidateRange (pInput, pMin, pMax, pTypeString) { if (vValidateDebug) { alert('fValidateRange('+pInput+', '+pMin+', '+pMax+', '+pTypeString+')'); } if (pMin == pMax) { return true; } lvValue = parseFloat(pInput.value, 10); if (lvValue < pMin || lvValue > pMax) { return fValidationError(pInput, 'Please enter ' + pTypeString +' between ' + pMin + ' and ' + pMax); } return true; }