-
-
Save bbshih/5870021 to your computer and use it in GitHub Desktop.
Additional JS to use Formtastic-Bootstrap with Client_Side_Validations
This file contains 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
ClientSideValidations.formBuilders["FormtasticBootstrap::FormBuilder"] = { | |
add: function (element, settings, message) { | |
if (element.data('valid') !== false) { | |
element.data('valid', false); | |
var $parent = element.closest('.controls'); | |
$parent.parent().addClass('error'); | |
$('<span/>').addClass('help-inline').text(message).appendTo($parent); | |
} else { | |
element.parent().find('span.help-inline').text(message); | |
} | |
}, | |
remove: function (element, settings) { | |
var $parent = element.closest('.controls'); | |
$parent.parent().removeClass('error'); | |
$parent.find('span.help-inline').remove(); | |
element.data("valid", true); | |
element.removeClass('error'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment