Skip to content

Instantly share code, notes, and snippets.

@fininhors
Last active June 26, 2016 21:37
Show Gist options
  • Select an option

  • Save fininhors/ea9f8e390bde37dd21bce191b24519c0 to your computer and use it in GitHub Desktop.

Select an option

Save fininhors/ea9f8e390bde37dd21bce191b24519c0 to your computer and use it in GitHub Desktop.
$('#login').click(function() {
if($('#nome').val() == ""){
alert('Voce deve informar o nome!');
$('#nome').focus();
}else if($('#email').val() == ""){
alert('Voce deve informar um email!');
$('#email').focus();
}else if($('#cpf').val() == ""){
alert('Voce deve informar o cpf!');
$('#cpf').focus();
}else if($('#telefone').val() == ""){
alert('Voce deve informar o telefone!');
$('#telefone').focus();
}else if($('#senha').val() == ""){
alert('Voce deve informar a senha!');
$('#senha').focus();
}else if($('#senha').val() !== $('#confsenha').val()){
alert('As senhas não conferem!')
}
else{
dados = {
"nome": $('#nome').val(),
"senha": $('#senha').val(),
"telefone": $('#telefone').val(),
"cpf": $('#cpf').val(),
"email": $('#email').val()
};
$('#errors').hide();
$.ajax({
type: 'POST',
url: 'cadastrar-usuario.php',
async: true,
complete: function(json) {
var json = eval('(' + json.responseText + ')');
if (json.success) {
var htmlSuccess = "<span>"+json.message+"</span>";
$('#errors').html(htmlSuccess);
$('#errors').show();
$('#formCadastro').each (function(){
this.reset();
});
}else {
var htmlSuccess = "<span>"+json.message+"</span>";
$('#errors').html(htmlSuccess);
$('#errors').show();
}
},
data: dados,
cache: false
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment