[html-formfu] output all possible errors in the form to provide javascript hooks (ajax)

Carl Franks fireartist at gmail.com
Thu Jul 31 16:21:00 BST 2008


2008/7/28 Yann Kerherve <yann at cyberion.net>:
> Hi,
>
> For some of my input fields, I'd like to setup an ajax "uniquifier" on the
> onblur() event. That would be a nice way to warn the user preemptively that
> a user name is taken for instance.
>
> My only problem is to give the error feedback to the user in a nice way with
> form-fu. What would be nice is to just reuse the error class that my
> server-side constraint is firing up if my form doesn't validate. But
> unfortunately I've found that the html for the errors are only generated
> when the form errors are processed.
>
> Ideally I guess I'd like to have a way to force all the errors to be
> rendered with a class="dormant" (display: none) by default. That set, my
> javascript could just change the class of the error if the user name is not
> unique, and I would only have one validation logic and one error message and
> class to render in the html.
>
> The only easy way I've found so far to emulate this is to just define
> manually another html bit outside of these errors, which has annoying side
> effects: duplication of the message and it's not easy to place correctly in
> the form (at least with my skills).
>
> Do you know another way to achieve that? Any pointer on how to modify htmlfu
> to do that I described above and if that would be complex or not?

I've done some work towards this, but never had a big-enough chunk of
time to get it finished.

There's a simple mock-up available of how the classnames, CSS and JS
would interact - available here:
http://www.formfu.org/tmp/client-side-constraint.html

I've not checked-in the work I've done on this, and would need to take
a look at it, to see if it's still any use.
Would you be interested in trying to get it working, based on that mock-up?
I'm not really likely to have the time to work on it in the next
couple months, at least.

Carl



More information about the HTML-FormFu mailing list