How do you guys feel about client side validation? Do you think its necessary or a waste of time?
How do you guys feel about client side validation? Do you think its necessary or a waste of time?
All depends on the app for me. You obviously have to validate server side regardless, but if there are things you can do client side to make it easier for the user, go for it. I'm thinking things like "username can only be lowercase alphanumeric"... if you can stop someone from filling out an entire form only to complain they ignored your rule... that's a nice feature.
There's a plugin out there that will take your AR model validations and convert them into javascript validations in your form. Can't recall the name, but that might simplify things for you.
Now... my personal pet peeve is forms that demand that phone numbers be in a certain format... I happen to like 555.555.5555 and that happens to be what my browser remembers. Drives me nuts when it whines that I have to use 555-555-5555. Just strip the non numbers and format it yourself! *grumble* *grumble*
The same is true for credit card numbers... point being if you can clean it up server side and still know what you've got, do it
-philip
Philip Hallstrom wrote:
How do you guys feel about client side validation? Do you think its necessary or a waste of time?
All depends on the app for me. You obviously have to validate server side regardless, but if there are things you can do client side to make it easier for the user, go for it. I'm thinking things like "username can only be lowercase alphanumeric"... if you can stop someone from filling out an entire form only to complain they ignored your rule... that's a nice feature.
Yes. And you don't need client-side validation for that, just a note. Sounds obvious, but you'd be amazed how often I see it omitted.
There's a plugin out there that will take your AR model validations and convert them into javascript validations in your form. Can't recall the name, but that might simplify things for you.
I'll check that out. That was actually something I liked about ColdFusion.
Now... my personal pet peeve is forms that demand that phone numbers be in a certain format... I happen to like 555.555.5555 and that happens to be what my browser remembers. Drives me nuts when it whines that I have to use 555-555-5555. Just strip the non numbers and format it yourself! *grumble* *grumble*
The same is true for credit card numbers... point being if you can clean it up server side and still know what you've got, do it
Agreed 100%. Don't make the user do things that the app should be smart enough to do itself.
-philip
Best,
The plugin is this: http://livevalidation.rubyforge.org/
I do both. Server-side is an obvious must. Client-side minimizes unnecessary hits on your server, and it has a better "feel" to the user. For example, if they neglect to fill in certain required fields, no reason to go all the way to your server and back to figure that out.
The problem I have found is its adding unnecessary work. If the server side has the validations, why do you need client side? Hitting the server is a non-issue as I believe most people fill out forms correctly on the first go.