dsjfrkvn818747 2013-12-27 09:19
浏览 101
已采纳

Jquery远程方法无法正常工作

I am new to jquery.. as form validation i am using the following form validation code..

just i added the remote method to check the email existance.. but it always saying the email is "already exist"

Here is the snippet of the code...

<script>
$(document).ready(function(){
    $("#f2").validate({
        debug: false,
        rules: {    
            email: {
                required:true,
                email:true,
                remote:'checkemail.php'
            },
            comments: {
                required:true
            }
        },
        messages:
        {
            email:{
                required:"Please enter valid email",
                remote:"Already Exist"
            }
        }});
});
</script>

Here is the form code..

   <form  name="f2" id="f2" method="post" action="">
       <div>
        <label >Email</label>
        <input type="text" name="email">
     </div>
    </form>

Here is the checkemail.php code..

<?php
    $email=$_GET['email'];
    $query="select email from emails where email='$email'";
    $res=  mysql_query($query);
    $cou=  mysql_num_rows($res);
    if($cou>0)
    {
        echo "true";
    }
    else{
        echo "false";
    }
?>

Update

i missed the db connection.. After putting the db connection in checkemail.php file, the remote method is not showing any message.. and form is submitting without checking the email is already exist why?

why the form behaving like this? Any idea..

Any suggestions are welcome...

  • 写回答

2条回答 默认 最新

  • dongyoucha0645 2013-12-27 11:19
    关注

    Modify you if statement like this if($cou>0) { echo 'false'; } else{ echo 'true'; }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?