pullo — 2010-02-11T11:53:26-05:00 — #1
So my question, what is the point of client side form validation if you have to do the same work again on the server?
Am I missing something?
Are there any cases where client side validation is the preferred choice (apart from speed)?
autisticcuckoo — 2010-02-11T12:12:27-05:00 — #2
Performance. Catching errors client-side will be much more efficient, since it doesn't require a round trip to the server. Less server load, faster feedback to the user.
It doesn't replace server-side validation, of course, but it enhances the user experience.
felgall — 2010-02-11T13:28:22-05:00 — #3
Server side validation is for the site owner. It makes sure everything has been entered correctly.
pullo — 2010-02-11T13:47:27-05:00 — #4
Thanks for the replies.
So, if I understand things correctly then, client side validation is a nice-to-have enhancement of the user's experience of your site, but can never be relied on if you have to be absolutely sure that certain fields have been filled out.
Do you know if many people bother to have both client side and server side validation?
mrhoo — 2010-02-11T13:54:15-05:00 — #5
You always have server side validation.
I often use that code to shape any client side validation, so it's not really two completely different sets of code to come up with.
You can also track server validation errors-
Figure what causes the user mistakes and you can improve the layout and instructions on the form to mitigate them.
paul_wilkins — 2010-02-11T15:27:18-05:00 — #6
Many people don't use both client-side and server-side, but then many people didn't believe that the earth revolves around the sun.
You can guarantee that people without server-side validation are at immediate risk of security breaches.
felgall — 2010-02-11T15:30:59-05:00 — #7
Anyone wanting to ensure that the entered info is valid will have server side validation.
Anyone wanting to try to make things easier for their visitors will have client side validation.
The only people who will not include both are those who have yet to learn what you have just learnt by asking the question in this thread.
pullo — 2010-02-11T15:39:23-05:00 — #8
Thanks for the replies.
A dichotomy indeed. The more I read about it, the more I see what it can do, and the more it causes me headaches (by having to ensure that everything degrades gracefully).
It's also annoying spending (not inconsiderable) time working on something that the client doesn't see or sometimes really appreciate (aforementioned graceful degradation).
paul_wilkins — 2010-02-11T15:57:18-05:00 — #9
After giving graceful degradation a go, web developers discovered more successful approach called progressive enhancement.
You start with just the basic HTML/CSS and get things working that way. It's always possible to get things working, using forms and buttons.
Then you end up with a page that works in both scripted and non-scripted environments, and it's a lot easier to create by building forward in such a manner.
autisticcuckoo — 2010-02-12T01:56:24-05:00 — #10
Everyone except rank amateurs, I should think.