jqueryvalidation和phpvalidation码问题
我的validation码领域
<img id="captcha" src="https://stackoverflow.com/questions/4533670/jquery-validate-and-php-captcha-issue/includes/secureimage/securimage_show.php?sid=" alt="CAPTCHA Image" />
我的validation码领域
<img id="captcha" src="https://stackoverflow.com/questions/4533670/jquery-validate-and-php-captcha-issue/includes/secureimage/securimage_show.php?sid=" alt="CAPTCHA Image" />
我的jqueryvalidationvalidation码的插件代码
seccode: { required: true, remote: { url: "checkuser.php", type: "post", data: { seccode: function() { //alert($("#seccode").val()); return $("#seccode").val(); } } } }
我的PHP
if($_POST['seccode']) { $securimage = new Securimage(); return $securimage->check($_POST['seccode']); }
我正在使用securimage进行validation码。 validation码的必要条件的消息正在运行。 但是远程条件不起作用。 当然我已经在php中包含了必需的类文件,并且还在php文件的开头启动了session_start()。
[注意]错误现在消失了。 现在有了新的东西。 第一次validation码在我关注时工作,但之后它会继续回调每次更改的validation方法..请参阅下面的firebug输出…
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
基本上,当您的jqueryvalidationvalidation码时,validation码代码会在validation发生的同一个函数中被销毁。 这就是我遇到问题的原因。 一旦再次刷新validation码,代码就可以正常工作。
如果远程validation成功,validation要求您返回“true”,我也更喜欢使用不同的服务器端检查进行远程validation,就像这个演示一样 。
所以validation码validation将是post_captcha.php
:
check($_POST['seccode']) == false) { // the code was incorrect // handle the error accordingly with your other error checking // or you can do something really basic like this //die('The code you entered was incorrect. Go back and try again.'); echo "false"; } else { echo "true"; } ?>
打开演示链接并启用firebug,只提交带有任何用户名的用户post_captcha.php
,然后用其中一个用户名(例如“ asdf ”)进行检查,你会发现响应就像我的post_captcha.php
一样!
易卜拉欣