# Client side validation - good, bad, or useless?

**URL:** <https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020>\
**Category:** Rails\
**Created:** [October 9, 2009, 11:29pm UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020 "2009-10-09T23:29:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 9, 2009, 11:29pm UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/1 "2009-10-09T23:29:50Z")

</div>

How do you guys feel about client side validation? Do you think its  
necessary or a waste of time?

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 9, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/2 "2009-10-09T23:37:19Z")

</div>

jko170 wrote:

> How do you guys feel about client side validation? Do you think its  
> necessary or a waste of time?

Good: gives user immediate feedback without the overhead of a server  
request.

Waste of time: Only works if JS is on. Not airtight, and may cause  
problems for browsers that don’t do JS.

With those facts in mind, determine what makes sense for your app. I  
rarely use client-side validation, but I could imagine places where it’s  
helpful.

The one you can’t forget is DB-level validation. The app is not  
sufficient to keep bad data out of the DB.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 9, 2009, 11:40pm UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/3 "2009-10-09T23:40:58Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 9, 2009, 11:53pm UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/4 "2009-10-09T23:53:13Z")

</div>

Philip H. 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,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 9, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/5 "2009-10-09T23:57:21Z")

</div>

The plugin is this: [http://livevalidation.rubyforge.org/](http://livevalidation.rubyforge.org/)

On Oct 9, 2:53 pm, Marnen Laibow-Koser \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 10, 2009, 10:13am UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/6 "2009-10-10T10:13:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [October 11, 2009, 1:31am UTC](https://www.ruby-forum.com/t/client-side-validation-good-bad-or-useless/177020/7 "2009-10-11T01:31:31Z")

</div>

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.
