17.3. Using validation within DbForms

Using validation within dbForms is as simple as setting an attribute in the 'dbform' tag. In dbForms v1.1, the attribute 'formValidatorName' has been added to allow a dbForm developer to associate a (dbForms) form to an [entry] in the Validation.xml file. Take for example the following JSP:

<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %>
    <db:dbform  tableName="bugs" captionResource="true" 
                    <db:textField fieldName="title" size="40"/> 
        <db:updateButton  caption="Save" /><br> 
        <db:deleteButton  caption="Delete"/><br> 

The 'formValidationName' attribute is set to 'bugs'. As you will see in the next section, the Validation.xml file includes an [entry] for 'bugs'. This [entry] will specify which fields will be validated, which validation(s) will be performed on each field and what error messages to display if the validation(s) fail.

Another feature which has been added to dbForms is support for client-side javaScript validation. When the attribute 'JavaScript Validation' is set to 'true', DbForms will generate methods to automatically validate client-side using the same rules found in Validation.xml.