form表单提交之前校验返回true之后自动提交

只有在submit按钮加onreturn 才可

<form:form action="save.do" method="post">
                <table class="table1 mTBLR_10_40" >
                    <tr>
     
                  <th colspan="4" class="fbk_th">用户信息</th>
                    </tr>
<div class="searchBtns">
                    <!--   <input type="submit" class="btn btn_green" value="提 交" /> -->
                    <input type="hidden" name="id" value="${roledetl.id}"/>
                    <input type="submit"  class="btn" value="提 交" onclick="return check()"/>
                    <input type="button"  class="btn" value="返 回" onclick="window.history.go(-1);"/>
               </div>
        </form:form>



function check() {
    var userName =$("input[name='userName']").val();
    var password =$("input[name='password']").val();
    var mobilePhone =$("input[name='mobilePhone']").val();
    var email =$("input[name='email']").val();
    var status =$("select[name='status']").val();
    var fullname =$("input[name='fullname']").val();
    /*  var orgId =$("select[name='orgId']").val(); */
    if(checkSubmitMobil()==false){
return false;
}
    if(checkSubmitEmail()==false){
  return false;
  }
    if(userName==null||userName==""||password==null||password==""){
    alert("请填写完整信息!");
    return false;
    }
    if(mobilePhone==null||mobilePhone==""||email==null||email==""){
    alert("请填写完整信息!");
    return false;
    }
    if(status==null||status==""||fullname==null||fullname==""){
    alert("请填写完整信息!");
    return false;
    }
    /* if(orgId==null||orgId==""||orgId=='0'||orgId==0){
    alert("请填写完整信息!");
    return false;
    } */
         return true;

}

猜你喜欢

转载自yuhuiblog6338999322098842.iteye.com/blog/2249795
今日推荐