Created
December 9, 2015 11:33
-
-
Save roniemicro/d05a4fe87cd8df42cb14 to your computer and use it in GitHub Desktop.
Pattern validator
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("pattern", function (b, a, c) { | |
if (this.optional(a)) { | |
return true | |
} | |
if (typeof c === "string") { | |
c = new RegExp("^(?:" + c + ")$") | |
} | |
return c.test(b) | |
}, "Invalid format."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment