jeudi 7 juillet 2016

How to check if email exists with jQuery?Working only when typing email,but not when copy-paste?


I'm trying to check if email exists with jQuery, but works only when typing, when I try with copy paste than shows that email is available, but its not. Please see below code.

JavaScript:

$(document).ready(function(){
    $('#test').keyup('check.php').show();
    $('#sign_up_email_input_first').keyup(function(){
        $.post('check.php', {email_sign_up: form.email_sign_up.value}, function(result){
            $('#test').html(result).show();}
        ); 
    });
});

PHP:

if(isset($_POST['email_sign_up']))
{
    $email = $_POST['email_sign_up'];
    $select = mysql_query("SELECT email FROM users WHERE email = '$email'") or die(mysql_error());
    $count = mysql_num_rows($select);
    if($email == NULL){
        echo "Choose Username";
    }else if(strlen($email)<=3){
        echo "";
    }else{
        if($count == 0){
            echo "Username is Available";
        }else if($count ==1){
            echo "Username is not Available";
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire