使用 jquery.validate.js插件中remote返回错误可是就是不出现账号已存在这个提示
user.php<?phpif($_GET['user']=='bn'){echo'fasle';}else{echo'true';}?>index2.js$(funct...
user.php
<?php if($_GET['user'] == 'bn'){ echo 'fasle'; }else{ echo 'true'; } ?>
index2.js
$(function(){ $('#reg').validate({ rules:{ user:{ required:true, minlength:2, remote:'user.php', }, pwd:{ required:true, minlength:6, } }, message:{ user:{ required:'必填项', minlength:jQuery.format('请输入不少于{0}个字符'), remote:'该账号已经被占用', }, pwd:{ required:'请输入密码', minlength:jQuery.format('请输入不少于{0}个字符'), } }, submitHandler:function(form) { alert('验证成功!'); } }); })validate.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title></title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/index2.js"></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico"> <link rel="stylesheet" href="css/style.css" /> </head><body> <form id="reg" action="null"> <p class="myerror"></p> <p> 账号:<input type="text" name="user" id="user" /> </p> <p> 密码:<input type="text" name="pwd" id="pwd" /> </p> <input type="submit" value="提交"/> </form></body></html> 展开
<?php if($_GET['user'] == 'bn'){ echo 'fasle'; }else{ echo 'true'; } ?>
index2.js
$(function(){ $('#reg').validate({ rules:{ user:{ required:true, minlength:2, remote:'user.php', }, pwd:{ required:true, minlength:6, } }, message:{ user:{ required:'必填项', minlength:jQuery.format('请输入不少于{0}个字符'), remote:'该账号已经被占用', }, pwd:{ required:'请输入密码', minlength:jQuery.format('请输入不少于{0}个字符'), } }, submitHandler:function(form) { alert('验证成功!'); } }); })validate.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title></title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/index2.js"></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico"> <link rel="stylesheet" href="css/style.css" /> </head><body> <form id="reg" action="null"> <p class="myerror"></p> <p> 账号:<input type="text" name="user" id="user" /> </p> <p> 密码:<input type="text" name="pwd" id="pwd" /> </p> <input type="submit" value="提交"/> </form></body></html> 展开
2016-01-20
展开全部
message 写错了,应该是messages,你看看
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询