Skip to content

Instantly share code, notes, and snippets.

@uhtred
Created October 21, 2014 20:58
Show Gist options
  • Save uhtred/25d09f451c8aebc6a1ae to your computer and use it in GitHub Desktop.
Save uhtred/25d09f451c8aebc6a1ae to your computer and use it in GitHub Desktop.
JS:jQuery Validate Tip To Disable Onkeyup Event In One Field.
jQuery.validator.setDefaults({
onkeyup: function(element) {
var _this = this,
$element = $(element),
element_id = $element.attr('id'),
classes = $element.attr('class') || '';
$.each(classes.split(' '), function() {
if (this in $.validator.classRuleSettings && $.validator.classRuleSettings[this].onkeyup !== false) {
$.validator.defaults.onkeyup.apply(_this, arguments);
return false;
}
});
if (this.settings.rules[element_id] && this.settings.rules[element_id].onkeyup !== false) {
$.validator.defaults.onkeyup.apply(this, arguments);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment