Java Reference
In-Depth Information
Figure 15.15:
The state of the contact form after entering some values
The form in Figure 15.15 shows the state after the user has typed some-
thing in. Notice that the “Last name” field is now in error; it is optional,
but with a minimum length of 2. Therefore, entering a single character
is not valid, and the field is in error.
The plug-in has a few limitations. Looking again at Figure 15.15 , the
phone number field is not in error despite the input being invalid. That's
because we're using our own custom type converter, which the plug-in
doesn't recognize. You'll also notice that the Cancel button is disabled
even though it is associated with a @DontValidate event handler in the
action bean.
These limitations very well may have been resolved by the time you read
these lines, so check http://www.stripes-stuff.org for the latest version.
You can also pass options to the applyStripesValidation ( ) function to cus-
tomize the behavior of the plug-in. For example, we can tell the plug-in
not to disable buttons. At the same time, we can specify the error CSS
class so that it matches the one used by Stripes:
Download ajax/web/WEB-INF/jsp/client_side_validation.jsp
var options = {
invalidClass: 'error',
disableSubmit: false
};
applyStripesValidation('${fmd.formId}', ${fmd}, options);
The form is still validated on the client side when the user submits the
form. The buttons are enabled, and a pop-up message appears if the
form is submitted with validation errors, as illustrated in Figure 15.16 ,
on the next page.
 
 
Search WWH ::




Custom Search