Skip to content

Instantly share code, notes, and snippets.

@fchevitarese
Created September 24, 2015 19:28
Show Gist options
  • Save fchevitarese/4d1eefe81450ca1dad8d to your computer and use it in GitHub Desktop.
Save fchevitarese/4d1eefe81450ca1dad8d to your computer and use it in GitHub Desktop.
new_ajax.js
$.ajax({
type:"GET",
data: {"id_cpf" : $('#id_cpf').val()},
url:"/user/validate/",
success:function(data){
switch (data) {
case "True":
$('#id_cpf').css(
{color: '#5BC24C', 'font-weight' : 'bold'}
);
$('#pessoa_pf').removeAttr('disabled', '');
$('#pessoa_pf').addClass('pull-right');
$('#cpf').removeClass('has-error');
break;
case "False":
$('#cpf').addClass('has-error');
$('#pessoa_pf').attr('disabled', '');
break;
case "Existe":
$('#id_cpf').css(
{color: '#E63F24', 'font-weight' : 'bold'}
);
$('#cpf').addClass('has-error');
$('#pessoa_pf').attr('disabled', '');
$(function(){
new PNotify({
title: 'ATENÇÃO',
text: 'O CPF já esta cadastrado',
type: 'error'
});
});
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment