onclick事件在谷歌、火狐中怎么提交

socialchen 2013-03-26 01:53:47
form表单中input(button)在IE9中能提交(触发onclick),但在IE10、chrome25.0.1364.172 m、firefox19.0.2中就不能提交(不加click事件也不能提交),如果换成input(submit)就都能提交,但不触发事件

大神们给看看呗
...全文
110 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
socialchen 2013-03-26
  • 打赏
  • 举报
回复
在线等!!有木有大神帮帮忙啊
socialchen 2013-03-26
  • 打赏
  • 举报
回复
引用 1 楼 u010024120 的回复:
你去火狐里面调试看看呗!应该可以提交
开启它的javascript? 还是怎么调呢?代码应该不会有问题了,在IE9可以运行的
socialchen 2013-03-26
  • 打赏
  • 举报
回复
js代码:
<script language="javascript" type="text/javascript">
	$(function(){
	
	   $("#tb th").css({color:"#FFFFFF"});
	   //登录
	   
	   $("#btnSubmit").click(function(){
		 if(checkUserName()&&checkPwd()&&checkCode()){
		 	$("#loginForm").submit();
		 	return true;
		 }else{
		  $("#msgResult").html("输入数据不合法!");
		  return false;
		 }
	   });
	   
	   var reg=/^(?:[\u4e00-\u9fa5]*\w*\s*)+$/;
	   //用户名文本框失去焦点
	   $("#txtName").blur(function checkUserName(){
		  if($("#txtName").val()==""){
			$("#txtName").css({backgroundColor:'red'});
			$("#msgName").html("请输入用户名!");
			return false;
		  }
		  if(!reg.test($("#txtName").val())){
			$("#txtName").css({backgroundColor:'red'});
			$("#msgName").html("不能有特殊字符!");
			return false;
		  }
		  $("#msgName").html("");
		  $("#txtName").css({backgroundColor:''});
		  return true;
	   });
	   
	   
	   //密码文本框失去焦点
	   $("#txtPwd").blur(function checkPwd(){
		  if($("#txtPwd").val()==""){
			$("#txtPwd").css({backgroundColor:'red'});
			$("#msgPwd").html("请输入密码!");
			return false;
		  }
		  if(!reg.test($("#txtPwd").val())){
			$("#txtPwd").css({backgroundColor:'red'});
		    $("#msgPwd").html("不能有特殊字符!");
			return false;
		  }
		  $("#msgPwd").html("");
		  $("#txtPwd").css({backgroundColor:''});
		  return true;
	   });
	   
	   
	   //验证码文本框失去焦点
	   $("#txtCode").blur(function checkCode(){
		  if($("#txtCode").val()==""){
			$("#txtCode").css({backgroundColor:'red'});
			$("#msgCode").html("请输入验证码!");
			return false;
		  }
		  if(!reg.test($("#txtCode").val())){
			$("#txtCode").css({backgroundColor:'red'});
			$("#msgCode").html("错误的验证码!");
			return false;
		  }
		  $("#msgCode").html("");
		  $("#txtCode").css({backgroundColor:''});
		  return true;
	   });
	   
	   
	   //键盘事件(这里是回车事件),验证通过则提交
       $(document).keydown(function(event) {
		  if(event.keyCode == 13&& checkUserName()&& checkPwd()&&checkCode()) {
		    $("#loginForm").submit();
		  }
	   });     
	});
    
    //更换验证码
	function ChangeCode(obj){
		obj.src=obj.src+"?temp=" + (new Date().getTime().toString(36));;
	}
	</script>
form表单:
<s:form id="loginForm" action="user_manager_doLogin.action"
				method="post">
				<div style="margin: 5px">
					<img src="${pageContext.request.contextPath}/images/login.jpg" title="欢迎登录"/>
				</div>
				<hr size="2" color="#FFFFFF" />
				<table width="100%" border="0" id="tb" cellspacing="5"
					cellpadding="0">
					<tr>
						<th width="35%" align="right">
							账  号:
						</th>
						<td width="65%" align="left">
							<s:textfield name="userItem.usrName" id="txtName"></s:textfield>
							<span id="msgName" style="color: #FF0000; font-size: 12px"></span>
						</td>
					</tr>
					<tr>
						<th align="right">
							密  码:
						</th>
						<td align="left">
							<s:password id="txtPwd" name="userItem.usrPassword" size="21"
								maxlength="20" onselectstart="return false;"
								ondragenter="return false;" onpaste="return false;"></s:password>
							<span id="msgPwd" style="color: #FF0000; font-size: 12px"></span>
						</td>
					</tr>
					<tr>
						<th align="right">
							验证码:
						</th>
						<td align="left">
							<s:textfield id="txtCode" name="code" size="5"></s:textfield>
							<img style="cursor: pointer;"
								src="${pageContext.request.contextPath}/servlet/CodeImage"
								alt="点击,更换验证码" onclick="ChangeCode(this);" />
							<span id="msgCode" style="color: #FF0000; font-size: 12px"></span>
						</td>
					</tr>
					<tr>
						<td>
							 
						</td>
						<td align="left">
							<input type="checkbox" name="rememberMe" id="checkbox" />
							<label for="checkbox" style="color: #FFFFFF;">
								1周内不用再登录
							</label>
						</td>
					</tr>
					<tr>
						<td>
							 
						</td>
						<td align="left">
						 <input type="button" id="btnSubmit" value="登录"
								style="background-color: #1C5BA6; border: #FFFFFF 1px solid; color: #FFFFFF" />
							<input type="reset" id="btnCancel" value="取消"
								style="background-color: #1C5BA6; border: #FFFFFF 1px solid; color: #FFFFFF" />
							<span id="msgResult" style="color: #FF0000; font-size: 12px"></span>
						</td>
					</tr>
				</table>
			</s:form>
onlyyou67 2013-03-26
  • 打赏
  • 举报
回复
你去火狐里面调试看看呗!应该可以提交

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧