The form is automatically submitted after the validation returns true before the form is submitted

只有在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==""){     return false;
    alert("Please fill in the complete information!");

    }
    if(mobilePhone==null||mobilePhone==""||email==null||email==""){
    alert("Please fill in the complete information!");
    return false;
    }
    if(status==null ||status==""||fullname==null||fullname==""){
    alert("Please fill in the complete information!");
    return false;
    }
    /* if(orgId==null||orgId== ""||orgId=='0'||orgId==0){
    alert("Please fill in the complete information!");
    return false;
    } */
         return true;

}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326843376&siteId=291194637