Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jquery Validation Plugin - Extension custom method
jQuery.validator.addMethod("extension", function (value, element, param) {
param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
}, "Please enter a value with a valid extension.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment