So, there's been a bit of talk about client side validaiton.
 
Tapestry already had most of the necessary hooks in place.  I had messed up, and forgot to include a way for a IValidator implementation to generate JavaScript on behalf of a ValidField.
 
It took me just a few minutes to put it all together.  I've updated StringValidator to enforce (when the containing form is submitted), the required and minimumLength properties.
 
Tapestry already had:
Dynamic JavaScript generation from a template
Easy way to "hook" form events (submit and reset).
Seperation of fields (ValidField) from validator (IValidator interface).
 
The default implementation is OK.  Other custom, implementations could be more flexible:
Validate the field on exit, rather than when form is submitted.
Alter the appearence of a field that is validated and in error.
 
I also added a "clientScriptingEnabled" flag to BaseValidator, which defaults on, but can be turned off, to disable client-side scripting.
 
I'll put together some more validators shortly.  The first was just a proof of concept.
 

Reply via email to