Skip to content

Instantly share code, notes, and snippets.

@OndeVai
Created March 12, 2012 22:15
Show Gist options
  • Save OndeVai/2025039 to your computer and use it in GitHub Desktop.
Save OndeVai/2025039 to your computer and use it in GitHub Desktop.
jquery validation plugin with knockout js custom binding handler
ko.bindingHandlers.jqValidation = {
update: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var accessor = valueAccessor();
if (accessor.enforce) {
$(element).find(':submit').removeClass('cancel');
$(element).validate({
submitHandler: function () {
if ($.isFunction(accessor.submitHandler))
accessor.submitHandler();
}
});
} else
$(element).find(':submit').addClass('cancel');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment