Which is the best way to validate forms??

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Saganxis
Forum Newbie
Posts: 2
Joined: Sat Apr 14, 2007 9:50 pm

Which is the best way to validate forms??

Post by Saganxis »

Hi everybody, I just wanted to know which 'd be the best way to validate forms.

I want to want to write some scripts to validate forms, but i want to know the differences between javascript and ajax.

For instance, http://www.formassembly.com/wForms/v2.0 ... dation.php is javacript validation and its very nice but not ajax.

Are there many security problems with the javascript validations, why ajax or php???
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Best way to validate a form is on the server side.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

Validation should always be done on the server side. Always. Then, on top of that, you can add client-side validation with javascript. Or Ajax.

The client side validation is there purely for the users' experience, and has nothing to do with security, because anyone can post anything to your server, completely ignoring your client side javascript validation. You improve the experience because when a user fills in a form he gets a warning for a missing or wrong field immediately instead of posting the form and having to wait for the entire page to reload.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I like using regex validation on the client side, but all form data needs to be validated on the server side anyway... without exception!
Saganxis
Forum Newbie
Posts: 2
Joined: Sat Apr 14, 2007 9:50 pm

Post by Saganxis »

Thanks for the replies... i 'll work on that. First with javascript validation and then with server-side validation.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

I would always tend to code validation on server, then on the javascript side. If not, don't forget to switch of javascript when testing the server side.
Post Reply