日期:2014-05-16  浏览次数:20981 次

【在线求助】JQuery中利用ajax验证邮箱是否存在,无法访问action,求助急急急!!! - Web 开发 / Ajax
页面的代码如下:
<%@page contentType="text/html;charset=utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户注册 - 当当网</title>
<link href="${pageContext.request.contextPath }/css/login.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/css/page_bottom.css" rel="stylesheet" type="text/css" />
</head>
<script src="../js/jquery-1.4.3.js" type="text/javascript"></script>
<script>
$(function(){
$("form :input.c").each(function(){
var $required = $("<strong style='color:red'> *</strong>");
$(this).after($required);
});

$('form :input').blur(function(){
var $parent = $(this).parent();
$parent.find(".formtips").remove();
//验证用户名
if( $(this).is('#email') ){
if( this.value == ""
|| (this.value != "" && !/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value)) ){
var errorMsg = '请检查邮箱格式';
  $parent.append('<span style="color:red" class="formtips onError">'+errorMsg+'</span>');
}else{
$.post("check.action",{data : $('#email').val()},
function(msg){
var okMsg=msg;
$parent.append("");
$parent.append('<span style="color:red"  

class="formtipsonSuccess">'+okMsg+'</span>');
})
}
 
}

 
//提交,最终验证。
$('#btnClientRegister').click(function(){
$("form :input.c").trigger('blur');
var numError = $('form .onError').length;
if(numError){
return false;

});
});  
</script>
<body>
<%@include file="../common/head1.jsp"%>
<div class="login_step">
注册步骤:
<span class="red_bold">1.填写信息</span> &gt; 2.验证邮箱 &gt; 3.注册成功
</div>
<div class="fill_message">
<s:form name="ctl00" method="post" namespace="/user" action="regist.action" id="f" theme="simple">
<s:token></s:token>
<h2>
以下均为必填项
</h2>
<table class="tab_login">
<tr>
<td valign="top" class="w1">
请填写您的Email地址:
</td>
<td class="a">
<input type="text" class="c" name="user.email" id="email" cssClass="text_input" />
<label>
请填写有效的Email地址<br />
</label>

</td>
</tr>


</table>
<div class="login_in">
<s:submit id="btnClientRegister" cssClass="button_1" value="注册"></s:submit>
</div>
</s:form>
</div>
<%@include file="../common/foot1.jsp"%>
</body>
</html>

struts2的配置文件:
<action name="check" class=&qu