On 1/12/06, Alvin Wang <[EMAIL PROTECTED]> wrote: > If the enhancements were added in the widgets ( id and javascript), it > seems to me that it would be cleaner. Formencode currently resides > completely on the server. Widgets handles the UI html generation > stuff. JS is in the UI. > > Wouldn't changing formencode to handle client validation cause problems > with ajax?
Clearly, formencode couldn't *directly* handle clientside validation. The idea is that the validation code for a value can conveniently live in a single place. Consider also that some validations can be represented by a regular expression... that kind of thing can work server or client side with just a little wrapping. Here's a little more specific of what I'm thinking: * we extend FormEncode's Validator (or FancyValidator or whatever it is) with a class that can also have a JSLink or JSSource. This could be ClientServerValidator or some such. * when a widget is asked for its javascript, it will check to see if its validator provides javascript. If so, it will include that javascript reference in the set that it returns. * when the template is rendered, the JavaScript for validation is included and is only included once because of the standard widget mechanism for JavaScript It's really quite doable, and you need to have both client side and server side validation as a general rule because you can't trust the client. Kevin

