简体   繁体   中英

Simple Client Side Validations in Rails

Basically, I have 10 validations on a form in my Rails app. If there are errors, the page refreshes & shows the errors in a box.

How can I show the error box without refreshing? I would like the box to display after clicking submit.

I saw a railscasts episode on client side validations using a gem but it seemed a bit too much & complicated for what I'm going after, plus I couldn't get it working. Looking through some of SO's similar questions, I know I'll have to use jquery/java but I'm still sort of lost. Could someone point me in the right direction

Thank you in advance.

You may want to consider either rolling your own client-side solution, or using a Javascript/jQuery library.

Personally, I've had a lot of luck with jQuery.validationEngine . It enables configurable and extensible form validations which work well out-of-the-box:

在此处输入图片说明

And while I haven't tried it myself, jquery-validation seem to be another popular client side validation library.

There are surely many other libraries out there for doing what you're looking to accomplish, but I'm fairly confident there's a good reason why these two are among the most popular solution. Additionally, both are well-documented and lay out concise instructions for simple implementations on their respective GitHub pages.

You can try https://github.com/jbmyid/rails_jq_validations

This is too simple to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM