Jquery Bubble Error Message
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack jquery validation tooltip error message Overflow the company Business Learn more about hiring developers or posting ads with us jquery validation tooltip options Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a using bootstrap tooltips to display jquery validation error messages community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up jquery tooltip to display validator messages up vote 9 down vote favorite 9 Im trying to
Validation Tooltip Css
display error messages for the jquery validator plugin(the bassistance one) as a tooltip above the component when the validation fails. The tooltip(also the bassistance one) just wont show, so I was wondering how to get this stuff working. My code so far: $("#loginForm").validate({ errorPlacement: function(error, element) { $(element).tooltip({ content: 'the error message goes here' }); } }); Also, I was wondering how I can get hold of the actual localised error tooltip validation in javascript message to display. I do not want to hardcode it into the tooltip as I've done in the snippet above. Any help is much appreciated! ;) jquery validation share|improve this question asked Dec 7 '10 at 20:55 Runar Halse 1,26832542 add a comment| 4 Answers 4 active oldest votes up vote 16 down vote accepted One way for doing this (without tooltip plugin) is with some off css code and some of imagination: $("#frmArticle").validate({ submitHandler: function(form) { form.submit(); }, onfocusout: function(element) { if ( !this.checkable(element)) { this.element(element); } }, rules: { name: { required: true } }, errorPlacement: function(error, element) { var container = $('
'); container.addClass('Ntooltip'); // add a class to the wrapper error.insertAfter(element); error.wrap(container); $("decided on a way of displaying validation errors and success messages on forms for my current project. I've turned this into a jQuery form error plugin on GitHub which provides some quick wins : A single how to display error message in jquery validations function call to display a validation message next to a field. A single function call
Jquery Validation Message Below Textbox
to remove a validation message and optionally displays a success image in its place. No additional css is required. In the GitHub
How To Display Error Message In Jquery Without Alert
project you'll find the Index.html which demonstrates a simple form with some validation. Here's a video of the plugin in action : How do I use jquery.formError? First of all you need to know when a http://stackoverflow.com/questions/4381476/jquery-tooltip-to-display-validator-messages form control has invalid data because it's then that you want to call the plugin. I've kept the validation logic in the demo simple so the focus is on the plugin. If you're using Backbone.js I can recommend the excellent backbone.validation plugin as it has the required valid/invalid callbacks you'll need. First you'll need to include the jQuery.formError.js plugin javascript file. Then, to display a validation error message on an input with an id of "name" http://www.garethelms.org/2012/01/jquery-form-error-plugin/ : $("#name").formError( "Name cannot be greater than 15 characters long"); To remove the validation message when you have successfully revalidated the value : $("#name").formError( {remove:true}); By default removing the validation message will place a validation success image in place of the error. So you'll need an icon for this like the one in the demo. To disable this behaviour : $("#name").formError( { remove:true, successImage: {enabled:false} }); The default image url is just "success.gif" which you can easily modify on a per-call basis : $("#name").formError( { remove:true, successImage: {src:"img/success.gif"} }); The plugin also gives an invalid control the css class invalid. I leave it up to you to decide the visual effect .invalid has on the control. In the demo.css file you'll see that it applies a red border. This css class is removed when you remove the error message. Why not put the validation message underneath the control? It's common for web forms to put their validation messages directly underneath the invalid control. Like this : I've had two problems with this approach : The insertion of the message makes the whole form increase in size. This is a visually jarring experience for the user but there is another problem with this. If you type in some invalid data and then press the submit button the first even to fir
sending it to your server. It saves you bandwidth, server load and it saves time for your users. Javascript form validation is not necessary, and if used, it does not replace strong backend server validation. That's why Parsley http://parsleyjs.org/doc/ is here: to let you define your general form validation, implement it on the backend side, and simply port it frontend-side, with maximum respect to user experience best practices. Parsley 1.x versions Parsley's current stable and supported versions are 2.x. If you still use a 1.x version, here is the related doc. But don't forget to upgrade! Data attributes Parsley uses a specific DOM API which allows you to configure pretty error message much everything directly from your DOM, without writing a single javascript configuration line or custom function. Parsley's default DOM API is data-parsley-. That means that if in config you see a foo property, it can be set/modified via DOM with data-parsley-foo="value". Configuration You'll see along this documentation and through examples various available configuration options. You can also view here all of Parsley's default configuration options. Installation Basic installation Parsley relies on jquery validation tooltip jQuery (>= 1.8), and it will need to be included before including Parsley. You will also need to include es5-shim if you want need to support IE8. Then, you can either use parsley.js unminified file or parsley.min.js minified one. These files and extras are available here. Finally, add data-parsley-validate to each
Parsley CSS Parsley adds many classes and elements in the DOM when it validates. You are strongly encouraged to customize them in your own stylesheets, but here is the "standard" Parsley css file that is used here on the documentation and examples, if you want to use it to bootstrap your projects with Parsley. Javascript installation Like for Basic installation, first include jQuery and Parsley. Then, simply use $('#form').parsley(options); or new Parsley('#form', options); (where options is an optional configuration object) to manually bind Parsley to your forms. That would look pretty much like this: Do not add data-parsley-validate to your forms Please be aware that Parsley looks at all data-parsley-validate occurrences in DOM on document load and automatically binds them if valid. Once a form or field