Validating inputs
We'll take the login form to demonstrate the use of Calyxo's form validation capabilities. The entered login data will be validated according to the following conditions:
- A user name is valid if it matches the regular expression ^[a-z][a-zA-Z0-9]{2,7}$. That is, it must start with a letter, followed by two to seven alpha-numerical characters.
- The password must not be empty.
-
The user id and password must not be equal.
NoteIn fact, the latter condition may seem somewhat strange. Don't mind! We just want to demonstrate the assertion of a condition depending on multiple fields.
All we have to do, is to describe the above conditions in a forms configuration file, load the forms plugin and change the /WEB-INF/jsp/login.jspx template to use the <forms:form>, <forms:text> and <forms:password> tags.
Note
The capabilities of the Calyxo Forms component go far beyond of
what we use in this example. We do not use converters and checkers,
here; neither we use form data beans; neither we define
custom validators; ...
Before we forget: copy CALYXO_HOME/calyxo-forms/calyxo-forms-*.jar to /WEB-INF/lib now.


