views:

53

answers:

1

Hi,

I'd like to add js validation to my forms, and that validation should be done without requests to my server.

So, say, I open a page with form, make some errors and js code show me (without single request to the server) that, say, this field is required, this field is too short, this field should be a number etc.

The main idea - DRY - this js code should be auto-generated and/or it should get validation rules from form.

Now I would implement such validation by writing custom js code (or use some form validation libraries), and I need to duplicate validation rules - in forms and in js code. This is not DRY :) Also I'll get some problems connected with error messages.

Is there solution for my need?

Thanks.

+1  A: 

i found this post in my bookmarks, but i haven't tried it out myself yet.

http://eikke.com/django-validation-an-introduction/

it's a small post that explains how to generate client side validation javascript from a Newform form (keeping you dry). some code is also available in a git repository

Stefan De Boey
Unfortunately it doesn't seem healthy and and live...
race1