# Client-side form validation

**URL:** <https://www.ruby-forum.com/t/client-side-form-validation/190365>\
**Category:** Rails\
**Created:** [June 18, 2010, 3:46pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365 "2010-06-18T15:46:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucas\_franceschi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@lucas\_franceschi](https://www.ruby-forum.com/u/lucas_franceschi)\
**Post date:** [June 18, 2010, 3:46pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365/1 "2010-06-18T15:46:23Z")

</div>

hey all,  
I am having a hard time looking for a plugin/gem to auto-validate a form  
in  
client-side, just like “live-validations”…

I tried to download and install it via “script/plugin install git://  
[github.com/porras/live-validations.git](http://github.com/porras/live-validations.git)”  
but no plugin was found…

i don’t wanna know from you guys HOW to do it, i just wanna know if  
anyone  
here uses this kind of validation, and which plugin/gem you use…

So, any ideas?

I`ll keep up the research for a way to do it easily…

Oh, important: i need a tool that does the validation according to model  
rules…

Thanks in advance.

Sempre Alerta Para Servir,

Lucas Franceschi  
Equipe de ProgramaÃ§Ã£o (AutomaÃ§Ã£o)  
SGI Sistemas  
(049) 9922-3360

---

<div class="post-metadata">

**Author:** ![lucas\_franceschi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@lucas\_franceschi](https://www.ruby-forum.com/u/lucas_franceschi)\
**Post date:** [June 18, 2010, 5:39pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365/2 "2010-06-18T17:39:55Z")

</div>

lucas franceschi wrote:

> I am having a hard time looking for a plugin/gem to auto-validate a form  
> in  
> client-side, just like “live-validations”…  
>   
> i don’t wanna know from you guys HOW to do it, i just wanna know if  
> anyone  
> here uses this kind of validation, and which plugin/gem you use…

Personally, I don’t generally use client-side validation. The problem  
that I see with doing validation client-side is that there is no  
guarantee that client-side scripting is enabled. Which means that any  
client-side validation must be duplicated server-side anyway.

Any differences in server and client validation algorithms could be  
confusing to the user, or worse end up allowing invalid data to reach  
the database. If you were relying on a particular client-side validation  
that did not exist server-side (either accidentally or by design) that  
could easily allow invalid input into the database.

I prefer to have all my validation logic side the model (server-side). I  
am of the opinion that it is the responsibility of the Model layer of  
MVC to validate data and not the View layer. Although the view objects  
can often assist the user with entering proper values, such as with  
drop-downs, checkboxes, radio buttons, etc. But, I would not rely on the  
view for full and proper input validation.

---

<div class="post-metadata">

**Author:** ![lucas\_franceschi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@lucas\_franceschi](https://www.ruby-forum.com/u/lucas_franceschi)\
**Post date:** [June 18, 2010, 5:58pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365/3 "2010-06-18T17:58:56Z")

</div>

> Personally, I don’t generally use client-side validation.  
> It’s painful when you upload a 10MB file with the form, and then  
> server-side validation tells you you forgot to type a description. Now  
> you need to reupload the 10MB file…

---

<div class="post-metadata">

**Author:** ![lucas\_franceschi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@lucas\_franceschi](https://www.ruby-forum.com/u/lucas_franceschi)\
**Post date:** [June 18, 2010, 8:30pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365/4 "2010-06-18T20:30:41Z")

</div>

Fernando P. wrote:

> > Personally, I don’t generally use client-side validation.  
> > It’s painful when you upload a 10MB file with the form, and then  
> > server-side validation tells you you forgot to type a description. Now  
> > you need to reupload the 10MB file…

That exactly why I included the word “generally.” I was not talking  
about specific cases such as you describe.

---

<div class="post-metadata">

**Author:** ![lucas\_franceschi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@lucas\_franceschi](https://www.ruby-forum.com/u/lucas_franceschi)\
**Post date:** [June 18, 2010, 8:40pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365/5 "2010-06-18T20:40:55Z")

</div>

Robert,  
I agree with you, but if there was a gem, that would just do the  
validation  
_based on the model rules_, wouldn’t it solve your problem, and mine’s?

well, there is that gem, that plugin, whatever… and there’s more than  
one,  
live-validation and client-side-validation, plugin and gem repectively,  
exists for this purpose… _but_ it’s not working… i just cant get it  
to  
work the way all the how-to’s say…

anyone here did use one of those???

Sempre Alerta Para Servir,

Lucas Franceschi  
Equipe de ProgramaÃ§Ã£o (AutomaÃ§Ã£o)  
SGI Sistemas  
(049) 9922-3360

---

<div class="post-metadata">

**Author:** ![lucas\_franceschi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@lucas\_franceschi](https://www.ruby-forum.com/u/lucas_franceschi)\
**Post date:** [June 18, 2010, 6:49pm UTC](https://www.ruby-forum.com/t/client-side-form-validation/190365/6 "2010-06-18T18:49:05Z")

</div>

> **[SitePoint Blog – The best Web Development & Design Blog](https://www.sitepoint.com/blog/)**
>
> The web’s best resource for web developers and designers to keep up-to-date and learn JavaScript, CSS, UX, WordPress, PHP and more

well, I do think your point is quite right, that’s why you never use  
pure  
javascript validation in the view…

what i am talking about, is a gem, or plugin, that you don’t need to say  
what to validate, it just, reads the model rules, and apply it in the  
view…

actually, ‘live-validations’ do it, but i’m having trouble making it  
work…

that’s why i came to you guys…  
anyone?  
Sempre Alerta Para Servir,

Lucas Franceschi  
Equipe de ProgramaÃ§Ã£o (AutomaÃ§Ã£o)  
SGI Sistemas  
(049) 9922-3360
