views:

37

answers:

3

I need to validate form on client-side and I was wondering if there is a rails plugin which will help me in this task? Maybe it will build javascript needed to validate certain model from ActiveRecord validations?

A: 

No you have to write your own javascript to validate the form.

You can apply some validation such as "field can't be blank" or "minimum characters required should be 6" or "value should be valid integer" on client side but how do you validate "Username should be unique" etc on client side?

Also You should validate your model on Serverside although you are applying Client Side Validations because User may Submit the Form by disabling javascript of Browser.

Salil
Not very helpful. Username uniqueness can be easily tested using Ajax request. And it is a bit silly to rely on client-side validation, such validation will just make validation response faster.
tig
do you mean Ajax Validations are Client Side Vaidations?If yes you are Wrong.
Salil
@tig: actually making validation response faster is the only goal you should aim for with client-side validation - and this is not silly, this is improving UI usability. Really checking things on the client is of secondary importance, cause it can be circumvented easily.
neutrino
+1  A: 

Hi tig,

validation from client side you have 2 options

1 - using pure javascripts (but you will not be able to validate somethings like 'uniqueness' which requires database support)

2 - Using Ajax do your validations from the back end You may use something like Ajax.Updater to show green color tick or red cross upon validations

And If you want to use ActiveRecord validations I would recommend 'livevalidation' plugin http://github.com/porras/livevalidation.git

hope this helps

cheers sameera

sameera207
livevalidation is what I was looking for!
tig
happy to see my answer is useful to you, happy programing :Dsameera
sameera207
A: 

I don't think that the client side validation is a good idea, because if there is on clients side means that the client can easily bypass it.

dombesz
Client side validation doesn't mean absence of server side validation
tig