Simple Client Side Validations in Rails - javascript

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.

You can Check Here.. Very good documentation..
https://sunilsharma3639.wordpress.com/2013/11/11/jquery-ketchup-plugin-for-client-side-form-validation/

Related

How can you use Python to fill out HTML forms that also have Javascript?

I am making a python program that automatically enters information into a form on a website. I looked at a module called mechanize at first but then I realized that it didn't support javascript. Is there any way to take a piece of information and insert it into a "form" on a website that uses javascript?
The website I am using is www.locationary.com.
If you login and then go to a place/business page like this,
http://www.locationary.com/place/en/US/California/Los_Angeles/Z_Pizza-p1001157911.jsp
then you will see a bunch of spots that need to be filled in. I looked at the page source and this "form" uses javascript. I just need a way to fill in those blanks now. Like I said, I tried mechanize and it didn't work but I also googled it and got nothing.
The "form" uses "onclick"
If you could offer any advice, I would really appreciate it.
Thanks.
I think probably the best way to do this is to use a framework that can operate through a browser. There are several options, but the most pythonic is windmill http://www.getwindmill.com/
I've found it useful on a number of projects.

Best jQuery TextEditor

Anyone know of a good Rich Text Editor preferably in jQuery, that has a good interface, is customize-able and easy to integrate in forms where submitting data is crutial?
I am making a website where people would need to send formatted texts..
I tried TinyMCE and i found it too much for what i wanted, then tried NicEdit, found some bugs in it, corrected some but it is a pain to get the typed HTML when i need to submit the form so i am looking for any alternative you might want to offer.
Thanks in advance
Try ckeditor. You can configure exactly which buttons you expose to your users, and it's possible even to have different configuration for differents users. I'm using it and have not found any important bug.
Simple but rich enough http://akzhan.github.com/jwysiwyg/

Is it appropriate to dispense with <form> tags when building an ajax application?

I'm working on an ajax application that makes extensive use of jQuery. I'm not worried about whether or not the application degrades gracefully.
So far I have been using Malsup's excellent jQuery form plugin to create forms that submit ajax requests. (For example, to submit updated record information.)
However I am considering dispensing with form tags altogether, and instead manually constructing $.post() statements when needed.
I'm wondering: What are peoples' thoughts on the best way to submit a large amount of information to the server - considering graceful degradation is not a requirement. Are there perils with just using $.post()?
Thanks in advance
Nope, not at all. That's all the plugin is doing anyway, under the hood.
The form tag does at least provide you with a nice structural grouping of your form tags, so that you can query for them more easily, though.
You've said it yourself - the peril is that it won't degrade gracefull!
Have jQuery add an extra field called UsingjQuery, then output your results based on whether this field is set or not.
This way users with javascript turned off (mobile clients, etc) will still be able to submit.
edit: Saw you mentioned 'degrades gracefully' but somehow didn't see it said 'not worried about' first!
Having a form tag does allow one javascript trick that jQuery doesn't support without: $('form').reset() ...
I stopped using FORM tags some time ago, but I also have a set of captured users that I know exactly what platform they are using.
I agree with David Pfeffer, however, I would also make the point that on occasion, form tags can get in your way. I've specifically had problems where I wanted multiple forms inside of a table, but that caused really ugly problems with positioning. So, I wound up dropping just the input elements in, copying them into a form that was elsewhere on the page, then submitting that form. It was a bit of a pain in the butt.
If you can do away with forms, and aren't worried about degradation, then I would highly consider it.

SharePoint Client JavaScript Documentation

I'm attempting to improve the usability of a client's SharePoint deployment via JQuery; and am hitting a brick wall when trying to find any sort of documentation of what's happening in core.js (aside from painfully digging through and trying to parse any sort of meaning out of it --all 250kb of it!!!!--) Anyone have any pointers, or documentation?
EDIT:
Sorry, to clarify my question, i'm familiar with using JQuery with SharePoint. My question involves hooking JQuery into SharePoint's own client API. My question is inspired by this post http://www.codefornuts.com/2009/09/forcing-sharepoint-into-asynchronous.html# ; where the author is overriding methods such as "SubmitFormPost" and "STSNavigate" in order to make the UI interaction more "AJAXy".
There's no documentation for core.js and it's really a black box. Any "messing" with it would make your installation unsupported. Because of its complexity and how important it is to SharePoint working correctly, I would be very careful before adding this sort of functionality. This is not a comment on your development ability, but IMHO there would need to be a serious business case along the lines of "we don't care if things break occasionally so things look cooler".
If you really want to continue this I think your best bet is to contact Einar! His is the only post I've ever seen that describes how to do AJAXify core.js.
I'm not entirely sure what you are trying to do, but you may want to take a look at Jan Tielen's work with jQuery and SharePoint. He has some interesting posts about calling the SharePoint web services with jQuery/Ajax to build much richer UIs. These are hosted within a SharePoint web part page using a Content Editor Web Part. I've used these techniques in a couple of applications with great results.
Check out this post for an example.

How to start up with jQuery in ASP.Net MVC?

I know C# really well, just started playing with ASP.Net MVC a few weeks ago, and almost zero javascript. I saw some people here recomending jQuery, so I'll try that out.
What resources/tutorial should I start with?
Here you go straight from the source:
http://docs.jquery.com/Tutorials
You may want to see
http://www.w3schools.com/JS/default.asp
Learning jQuery is a good place to start.
The jQuery site has excellent documentation and lots of samples. It really is the best place to get started.
For general JavaScript I would read JavaScript The Good Parts
Try checking out Rob Conery's blog post, Putting the M back in MVC. It integrates a pre version 3 of Subsonic, ASP.Net MVC, and jQuery(core, UI, and forms). It's quick and easy to build simple web applications. It will move you up the jQuery learning curve fairly quickly if you are looking at Ajax, forms validation, and some basic CSS twiddling.
The nice thing about this approach is you get working applications that allow you to try different approaches.

Categories