onblur文本框生成警告,该电子邮件已存在于数据库中

i have a function of PHPthat response that the data is unique are not, i want to call it in JavaScript. if the email is already exist it stop to the form to submit else form can b submitted.

    <?php include'class.php'; ?>
    Enter your email: <input type="text" id="email" onblur="myFunction()">
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
     <script type="text/javascript">
       function myFunction() { $(document).ready(function() {
            var x = document.getElementById("email").value;
    if(y=0){
            alert('already exist');}
        });}
        </script>
it is presented in a php class file
public function unique($table,$col,$comp){include'db.php';
            $query="SELECT count(*) as flag FROM $table where $col='$comp'";            
            $result = mysqli_query($con,$query);
            while($row = mysqli_fetch_array($result)){$flag=$row['flag'];}
            if($flag==0){return 0;}else{return 1;}} 

should be if(y==0) - you omitted one equal sign. And why y, not x? It should be if (x==1) Also the input lacks value, which I think was to be $flag