0

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?

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

livevalidation is what I was looking for!
happy to see my answer is useful to you, happy programing :D sameera
0

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.

3 Comments

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.
do you mean Ajax Validations are Client Side Vaidations?If yes you are Wrong.
@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.
0

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.

1 Comment

Client side validation doesn't mean absence of server side validation
0

Have a look at this gem: https://github.com/bcardarella/client_side_validations . It defines client side validations from your model validations, reducing the risk that your frontend and backend validations get out of sync over time.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.