Created
July 15, 2016 13:30
-
-
Save YurePereira/cf2478ff066d644f72262c47163705af to your computer and use it in GitHub Desktop.
Validar CNPJ remotamente com jQuery Validation
This file contains hidden or 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
| //Adicionar validação do CNPJ. | |
| function adicionarValidacaoCNPJ(valid) { | |
| var cnpjEmpresa = $('#cliente_prop_cli_nr_cnpj_empresa'); | |
| cnpjEmpresa.rules('remove', 'remote'); | |
| if (valid) { | |
| cnpjEmpresa.rules('add', { | |
| remote: { | |
| url: "@Url.Action("cnpjClienteExistente", "Proposta")", | |
| type: 'POST', | |
| data: { | |
| id_cliente: function () { | |
| return $('#cliente_prop_cli_id').val(); | |
| } | |
| } | |
| }, | |
| messages: { | |
| remote: "CNPJ já existente no sistema.", | |
| }, | |
| }); | |
| } else { | |
| cnpjEmpresa.rules('remove', 'remote'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment