Struts Validator Framework provides an easy-to-use mechanism for performing client-side validation. It's very useful to validate some fields on the client-side before sending the data to the server for processing. By this way we can ensure that the data send to the server is valid. Performing validations on the client-side save the user a round trip time to the server.
Let's take a login application for our example. Our LoginForm extends DynaValidatorForm.
Enter only the user name and click the Login button. The following error message will be displayed.
Enter a User Name and a Password less than six characters. The following error message will be displayed.
Enter the User Name as "tutorials4u" and a Password greater than six characters. The following success page will be displayed.
You can download the source code of this example by clicking on the Download link below.