2

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.

3 Answers 3

2

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:

enter image description here

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.

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

3 Comments

Any simpler ones? Sort of like a simple flash error message box listing all the errors without refreshing the page?
Flash errors, by definition, require the business logic performed within a controller – so a page load is necessary. jQuery.validationEngine is pretty simple to implement... have you given it a try?
Not the answer I was looking for but it will come in handy. Thx
1

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

This is too simple to use.

Comments

1

You can Check Here.. Very good documentation..

https://sunilsharma3639.wordpress.com/2013/11/11/jquery-ketchup-plugin-for-client-side-form-validation/

1 Comment

Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference.

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.