Created
April 3, 2012 23:56
-
-
Save shawn-simon/2296466 to your computer and use it in GitHub Desktop.
Bootstrap.css defaults for jquery Validator
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
$.validator.setDefaults({ | |
errorElement:"label", | |
errorClass:"error", | |
validClass:"success", | |
highlight: function(element, errorClass, validClass) { | |
if (element.type === 'radio') { | |
this.findByName(element.name).parents('.control-group').addClass(errorClass).removeClass(validClass); | |
} else { | |
$(element).parents('.control-group').addClass(errorClass).removeClass(validClass); | |
} | |
}, | |
unhighlight: function(element, errorClass, validClass) { | |
if (element.type === 'radio') { | |
this.findByName(element.name).parents('.control-group').removeClass(errorClass).addClass(validClass); | |
} else { | |
$(element).parents('.control-group').removeClass(errorClass).addClass(validClass); | |
} | |
}, | |
errorPlacement: function(error, element) { | |
var inlineHelpBlocks = element.parents('.control-group').find('.help-inline') | |
if (inlineHelpBlocks.length > 0) | |
{ | |
error.insertAfter(inlineHelpBlocks[inlineHelpBlocks.length - 1]) | |
} | |
else | |
error.insertAfter(element); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment