Created
November 6, 2019 15:42
-
-
Save UbaldoRosas/58236e95db504f0c387acbb8a2c11b18 to your computer and use it in GitHub Desktop.
Jquery Validation Plugin - Extension custom method
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
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