jquery validation remote 验证Email,返回值正确,可是不现实错误信息。
我使用jqueryvalidationremote验证Email.如果输入test@example.com,那么显示:"Alreadysubscribed"。我用fire...
我使用jquery validation remote 验证Email.如果输入test@example.com,那么显示:"Already subscribed" 。我用firebug检查,发现当我输入test@example.com的时候,返回值为true, 但是"Already subscribed"的错误信息就是不显示,我也不知道为什么,向大家请教。
HTML:
<script type="text/javascript">
$(function(){
$("#subscribe_test").validate({
rules: {
fullname: { required: true, maxlength: 64 },
email: { maxlength: 32,remote: "apost.jsp" },
website: { maxlength: 32 }
},
messages: {
email:{remote: "Already subscribed" }
}
});
});
</script>
<form id="subscribe_test" action="" method="POST">
<table>
<tbody>
<tr>
<td><label for="fullname">Full name: *</label></td>
<td><input id="fullname" type="text" /></td>
</tr>
<tr>
<td><label for="email">Email: *</label></td>
<td><input name="email" id="email" class="required" type="text" /></td>
</tr>
<tr>
<td><label for="website">Website:</label></td>
<td><input id="website" type="text" /></td>
</tr>
<tr>
<td><input type="submit" /></td>
<td></td>
</tr>
</tbody>
</table>
</form>
apost.jsp:
String email = request.getParameter("email");
String a="true";
a=a.trim();
String b="false";
b=b.trim();
if(email.equals("test@example.com"))
{
response.getWriter().write(a);
}
else
{
response.getWriter().write(b);
} 展开
HTML:
<script type="text/javascript">
$(function(){
$("#subscribe_test").validate({
rules: {
fullname: { required: true, maxlength: 64 },
email: { maxlength: 32,remote: "apost.jsp" },
website: { maxlength: 32 }
},
messages: {
email:{remote: "Already subscribed" }
}
});
});
</script>
<form id="subscribe_test" action="" method="POST">
<table>
<tbody>
<tr>
<td><label for="fullname">Full name: *</label></td>
<td><input id="fullname" type="text" /></td>
</tr>
<tr>
<td><label for="email">Email: *</label></td>
<td><input name="email" id="email" class="required" type="text" /></td>
</tr>
<tr>
<td><label for="website">Website:</label></td>
<td><input id="website" type="text" /></td>
</tr>
<tr>
<td><input type="submit" /></td>
<td></td>
</tr>
</tbody>
</table>
</form>
apost.jsp:
String email = request.getParameter("email");
String a="true";
a=a.trim();
String b="false";
b=b.trim();
if(email.equals("test@example.com"))
{
response.getWriter().write(a);
}
else
{
response.getWriter().write(b);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询