form表单中input(button)在IE9中能提交(触发onclick),但在IE10、chrome25.0.1364.172 m、firefox19.0.2中就不能提交(不加click事件也不能提交),如果换成input(submit)就都能提交,但不触发事件大神们给看看呗chromefirefoxinputieclick事件

解决方案 »

  1.   

    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">
    账&nbsp;&nbsp;号:
    </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">
    密&nbsp;&nbsp;码:
    </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>
    &nbsp;
    </td>
    <td align="left">
    <input type="checkbox" name="rememberMe" id="checkbox" />
    <label for="checkbox" style="color: #FFFFFF;">
    1周内不用再登录
    </label>
    </td>
    </tr>
    <tr>
    <td>
    &nbsp;
    </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>
      

  2.   


    开启它的javascript?还是怎么调呢?代码应该不会有问题了,在IE9可以运行的