doson1998 2010-12-26 11:36
浏览 46
已采纳

jquery验证和php验证码问题

my captcha field

<p style="height:30px;"><img id="captcha" src="includes/secureimage/securimage_show.php?sid=<?php echo md5(time()); ?>" alt="CAPTCHA Image" />
<a tabindex="-1" style="border-style: none; margin-left:5px;" href="#" title="Refresh Image" onclick="document.getElementById('captcha').src = 'includes/secureimage/securimage_show.php?sid=' + Math.random(); return false"><img src="images/refresh.png" alt="Reload Image" onclick="this.blur()" style="vertical-align: top; border:0;" /></a></p></div>
<p><label for="seccode">Verification Code:<span class="important">*</span></label><input id="seccode" type="text" name="seccode" size="10" class="required" /></p>

my jquery validate plugin code for captcha

seccode: {
        required: true,
        remote: {
        url: "checkuser.php",
        type: "post",
        data: {
        seccode: function() {
            //alert($("#seccode").val());
            return $("#seccode").val();
        }
    }
}
}

my php

if($_POST['seccode'])
    {
        $securimage = new Securimage();
        return $securimage->check($_POST['seccode']);
    }

i am using securimage for captcha. message for required condition for captcha is working. but remote condition is not working. Ofcourse i have included required class file in php and also started session_start() in the start of php file.

[note] the error gone now. something new comes now. First time the captcha works when i focus out, but after that it continues to callback the validation method on each change.. see the firebug output below...

GET http://localhost:8080/property/html/captcha.php?seccode=pzubwg
GET http://localhost:8080/property/html/captcha.php?seccode=pzubwg

200 OK
        36ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=l
GET http://localhost:8080/property/html/captcha.php?seccode=l

200 OK
        39ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=ln
GET http://localhost:8080/property/html/captcha.php?seccode=ln

200 OK
        41ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnr
GET http://localhost:8080/property/html/captcha.php?seccode=lnr

200 OK
        36ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrg
GET http://localhost:8080/property/html/captcha.php?seccode=lnrg

200 OK
        38ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgu
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgu

200 OK
        32ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgue
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgue

200 OK
        25ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgu
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgu

200 OK
        34ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrg
GET http://localhost:8080/property/html/captcha.php?seccode=lnrg

200 OK
        40ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgv
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgv

200 OK
        42ms    
jquery.min.js (line 140)
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgve
GET http://localhost:8080/property/html/captcha.php?seccode=lnrgve

200 OK
        37ms
  • 写回答

2条回答 默认 最新

  • douliao5467 2011-01-04 12:05
    关注

    Basically when your jquery validates the captcha code, the captcha code is destroyed in the very same function where the validation occurs. Thats why i was getting the problem. The code works fine once you refresh the captcha again.

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

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口