onclick事件在谷歌、火狐中怎么提交 form表单中input(button)在IE9中能提交(触发onclick),但在IE10、chrome25.0.1364.172 m、firefox19.0.2中就不能提交(不加click事件也不能提交),如果换成input(submit)就都能提交,但不触发事件大神们给看看呗chromefirefoxinputieclick事件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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> 开启它的javascript?还是怎么调呢?代码应该不会有问题了,在IE9可以运行的 struts2.1 使用 convention plugin 时配置拦截器问题 启动tomcat报错 请高手指点 用Hibernate生成类的相关问题 求struts2的电子书 请问怎么在servlet中实现跳转的页面是弹出的新窗口 jboss事务超时的解决方法 困惑问题 求tomcat与java web开发技术详解 jbuilder连MS-SQL出现问题 请问我怎么在EJB的CREATE 中传参数. GWT-EXT中鼠标点击Menu该怎样监听 java web 前段 IE bug
<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>
开启它的javascript?还是怎么调呢?代码应该不会有问题了,在IE9可以运行的