-
-
Save ouranos/1821223 to your computer and use it in GitHub Desktop.
Javascript extension for client_side_validations to support Formtastic Bootstrap form builder (v2.0)
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