Recommend a javascript form validator

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Recommend a javascript form validator

Post by JayBird »

I've been looking around at some of the form validation library's built on different frameworks and was wondering what everyone is using.

Ive tried a few but some seem overly complicated and some don't seem to quite live up to the hype.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

I have to admit that I am lazy. As you have to validate in PHP anyway (to easy to rig values otherwise even if it is a post) I don't bother to validate using javascript.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Yep, i used to be like that, but things start getting tricky when in the same form you have multiple file upload forms.

Say the user has to select 5 files to upload, then submit the form for the fields to be checked, if there are any errors with any of the non-file fields, and the form is redisplayed, the user needs to select the files again (unless the files are uploaded and saved even if an error occurs).

I just think it leads to a better user experience by having JS validation coupled with PHP validation
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

In this instance, although a bit of potential overkill/extra traffic I would use AJAX. You only have to maintain one validation code block in PHP rather than keep PHP and javascript validations in sync.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

Or let php create the javascript (-array) so you only have to maintain one validation code block
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Anyway, back to the ACTUAL question.

Can anyone recommend any validation library's they use?!
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

The ones I like are from the code libraries from the books:

- Modern web design using javascript and Dom by Stuart Langridge (sitepoint book)
- Beginning javascript with dom scripting and ajax by Christian heilmann.

I'm almost sure you can download the code examples even without buying the books.
Post Reply