Jquery email validation
<p>After getting help from @juhana (thank you again) I ended up with theese codes to validate email input:</p>

<p>validate email:</p>

<pre><code>function validateEmail(){
var a = $("#email").val();
  $.ajax({
  type: "POST",
  url: "check_email.php",
  data: "email="+a,
  success: function(rsp){
   //if it's valid email
   if(rsp == "ok"){
    email.removeClass("error");
    emailInfo.text("");
    emailInfo.removeClass("error");
    return true;
}

else
//if it exists
if(rsp == "exists" ){
 email.addClass("error");
 emailInfo.text("E-mail already in use");
 emailInfo.addClass("error");
 return false;
}

else
//if it's NOT valid
if(rsp == "invalid"){
 email.addClass("error");
 emailInfo.text("Please type a valid E-mail");
 emailInfo.addClass("error");
 return false;
 }
}
});
}
</code></pre>

<p>check_email.php</p>

<pre><code>&lt;?php
require_once('db_conn.php');
require_once('is_email.php');

$email = mysql_real_escape_string($_POST['email']);
if (is_email($_POST['email'])){
echo 'ok';

$checkemail = mysql_query("SELECT E_mail FROM orders WHERE E_mail='$email'");
$email_exist = mysql_num_rows($checkemail);

if($email_exist&gt;0){
echo 'exists';
}
}else{
echo 'invalid';
}
?&gt;
</code></pre>

<p>Now 2 out of 3 are working the "ok" and the "invalid" ones... the "exists" doesn't.</p>

<p>What's wrong here???</p>

<p>Thank you</p>
