building a generic validation (in javascript)

Permabanned
Joined
16 Dec 2002
Posts
10,237
ok i have few forms on different pages (registration pages) that have stuff like: email, password on one page, user details on another (ie: name and stuff) and user information on another.

currently i have validation for each which sort of does the same thing ie checks to see if given field is empty or whatever... obv some pages have a drop down box, a checkbox. but i was wondering if i could create a function which would work on ALL different pages. rather then me copying a function three times and changing it a little bit each time to accommodate drop down boxes etc..
 
Soldato
Joined
26 Dec 2003
Posts
16,522
Location
London
If you were feeling ambitious you could create something server side that both generated the forms and provided validation for them. You can determine lots of stuff from the database field; you know that a DATETIME field must be in a format that's compatible with your database, and that a VARCHAR(20) must not have more than 20 characters in it. Then you could provide ways of extending this default behavior for custom fields, like emails and whatnot.

Django does this and it's amazing, but it's Python.
 
Back
Top Bottom