Skip to content

Instantly share code, notes, and snippets.

@uhtred
Created October 16, 2014 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uhtred/833f3b957d61e94fbff6 to your computer and use it in GitHub Desktop.
Save uhtred/833f3b957d61e94fbff6 to your computer and use it in GitHub Desktop.
JS:Extend jQuery Validate Native Methods
$.validator.addMethod("cMaxlength", function(value, element, param) {
return $.validator.methods.maxlength.call(this, value, element, param[1]);
}, '{0}');
/*
USE
$.validator.addClassRules({
'credit-card': {
cMaxlength: [ 'Invalid number.', 19 ]
}
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment