SPS Home    >   Dgreath    >   Business Rules


Business Rules Implemented in Javascript

isComplexPwd()
isCreditCard()
isEmail()
isGreaterThan()
isIdentical()
isInteger()
isLessThan()
isNotNull()
isSSAN()
isPhoneNumber()
isWithinLength()
isZipCode()

isFormValid() Method

The following snippet demonstrates a method to render a summary alert box if at least one validation test fails. This method is event triggered by the onsubmit event of the named form i.e. onsubmit="return isFormValid()". If the function returns true, the form's "action" will process, if it returns false, it will not process. Note: if a page contains more than one form to validate, each form will require a uniquely named instance of the following method.
This is not a codebehind method and will require a reference in the markup as noted above.

isFormValid()
 

  

Hint: use the following argument in the form element  to test the validation script. action="javascript:alert('Passed Validation')" Then when everything is working correctly, replace it with the real action script or page call.

Another popular method is the adjacent span tag technique shown on the accompaning pages. This method posts the error message to a span tag in close proximity to the watched control and is fired each time the control loses focus. Both summmary and span tag methods can be used together quite nicely. The summary provides a list of "things to fix" when the submit button is clicked, while the span tag method gives immediate feedback at the point of data entry.