Adding Form Validation to Bettergig.com page 4

 by Tom Muck

After applying the SB to each element in turn, you can browse the page and try to enter invalid or no data. The error page will pop up with the error message that applies to the field that wasn't filled out properly:

 

Validation could easily be handcoded as well, if you decide not to use the Basic-UltraDev Server Behavior. A sample validation for a blank field would be something like this (ASP VBScript):

If Request("SeekFirstName") = "" Then
  Response.Redirect("../error/error.asp?error=Must+enter+a+first+name")
End If

 

The Server Behavior inserts a function that can handle various types of validation, and then calls the function for each form element that it has been applied to. This is superior in many ways, because the function only has to be written to the page once. It also uses a Switch/Case statement, so the extra code is never executed, making it fairly efficient.

Tom Muck

<<< Previous Home >>>