Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created July 15, 2016 13:30
Show Gist options
  • Select an option

  • Save YurePereira/cf2478ff066d644f72262c47163705af to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/cf2478ff066d644f72262c47163705af to your computer and use it in GitHub Desktop.
Validar CNPJ remotamente com jQuery Validation
//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