Field Validation

This example shows you how to setup field validation on the Java Server Page. View the Tab labelled Java and scroll to the bottom where we create the instances of the Fields. Note how we create instances of class Validate and how we use enum values to set for EMAIL_REQUIRED and DATE_FORMAT. We also use a constant value from class DateFormat to set the specific format for the Date field.

If a field does not require validation, there is a special Validate.Type named NOTREQUIRED. You might think this unnecessary, however I assure you it is quite necessary. In a world where we have unscrupulous individuals who wish to perform hacks on database systems, JED has incorporated validation code for any illegal character sequences that would potentially cause an SQL Insertion attack. It is in your best interest to use the NOTREQUIRED type as a bare minimum to ensure validation checks are being performed behind the scenes and protecting your most valuable asset, the database. In this example all fields are required to perform validation on their particular type, but in addition JED is also checking for invalid character sequences. You can test this when you bring up the EDIT form and type in any field the term "delete" as an example.

Live example


FIRSTNAME LASTNAME EMAIL_ADDRESS START_DATE
Loading data from server
FIRSTNAME LASTNAME EMAIL_ADDRESS START_DATE


Javascript
HTML
Java
Includes