javascript - Valid email still returns false -
so i'm trying check if email valid, know can use js this, prefer way. here's i'm doing
//get data if(isset($_post['email'])){ $email = htmlspecialchars($_post['email'], ent_quotes, 'utf-8') } else{ header('location: /'); } if(!filter_var($email, filter_validate_email)){ echo 1; } else{ echo 0; } and js
$(document).ready(function() { //listens typing on desired field $("#email").keyup(function() { //gets value of field var email = $("#email").val(); //here send desired data php file using ajax $.post("../classes/validate.php", {email:email}, function(result) { if(result == 1) { //email valid console.log("good"); } else { //email invalid console.log("bad"); } }); }); }); now no matter enter, it's returning bad. valid email. ideas?
you're missing semicolon right after store email variable.
//get data if(isset($_post['email'])){ $email = htmlspecialchars($_post['email'], ent_quotes, 'utf-8'); } else{ header('location: /'); } if(filter_var($email, filter_validate_email)){ echo 1; } else{ echo 0; }
Comments
Post a Comment