Created
April 15, 2014 13:48
-
-
Save codescribblr/10734268 to your computer and use it in GitHub Desktop.
Using jQuery.validate() with bootstrap 3 styles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // override jquery validate plugin defaults | |
| $.validator.setDefaults({ | |
| highlight: function(element) { | |
| $(element).closest('.form-group').addClass('has-error'); | |
| }, | |
| unhighlight: function(element) { | |
| $(element).closest('.form-group').removeClass('has-error'); | |
| }, | |
| errorElement: 'span', | |
| errorClass: 'help-block', | |
| errorPlacement: function(error, element) { | |
| if(element.parent('.input-group').length) { | |
| error.insertAfter(element.parent()); | |
| } else { | |
| error.insertAfter(element); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment