-1
When I type an already registered email it displays the message saying that the email is already in use and disables the Ubmit button, but when I type the right email the message does not disappear, how to do for when the email is correct the message exit and enable it?
verificaEmail.php
#Recebe o Email Postado
$emailPostado = $_POST['email'];
#Conecta banco de dados
include('conn.php');
$sql = mysqli_query($conn, "SELECT * FROM cliente WHERE email = '{$emailPostado}'") or print mysql_error();
#Se o retorno for maior do que zero, diz que já existe um.
if(mysqli_num_rows($sql)>0) {
echo json_encode(array('email' => 'Email já cadastrado'));
}
}
?>
<div class="wrap-input100">
<input class="input100" type="email" id="email" name="email" placeholder="Email" required>
<div class="resposta" id='resposta'></div>
</div>
<button class="login100-form-btn" id="submit">Cadastrar</button>
<script>
//Verifica email
var email = $("#email");
email.change(function() {
$.ajax({
url: 'verificaEmail.php',
type: 'POST',
data: {
"email": email.val()
},
success: function(data) {
console.log(data);
data = $.parseJSON(data);
$("#resposta").text(data.email);
$("#submit").attr("disabled", true);
}
});
});
</script>