Created
March 17, 2013 09:21
-
-
Save rafaellyra/5180792 to your computer and use it in GitHub Desktop.
Adiciona methodo para validação por regex no plugin jQuery Validate.
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
$.validator.addMethod('regex', function (value, element, regexp) { | |
var check = false, | |
re = new RegExp(regexp); | |
return this.optional(element) || re.test(value); | |
}, 'Favor verificar os valores digitados.'); | |
/* | |
Exemplo de uso : | |
rules: { | |
'name': { | |
required: true, | |
regex: /^[0-9A-Z]{2}[57C]{1}[0-9A-Z]{14}$/i | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment