Three ways to submit a form after js validation


**The first: **

<script type="text/javascript">
         function check(form) {

          if(form.userId.value=='') {
                alert(" Please enter the user account !");
                form.userId.focus();
                return false;
           }
       if(form.password.value==''){
                alert(" Please enter your login password !");
                form.password.focus();
                return false;
         }
         return true;
         }
</script>
<form action="login.do?act=login" method="post">
 The user account
  <input type=text name="userId" size="18" value="" >
<br>
  The login password      
<input type="password" name="password" size="19" value=""/>     
 <input type=submit name="submit1" value=" landing " onclick="return check(this.form)"
</form>  
 

**The second, **

<script type="text/javascript">
         function check(form) {

          if(form.userId.value=='') {
                alert(" Please enter the user account !");
                form.userId.focus();
                return false;
           }
       if(form.password.value==''){
                alert(" Please enter your login password !");
                form.password.focus();
                return false;
         }
         return true;
         }
</script>
<form action="login.do?act=login" method="post" onsubmit="return check(this)">
 The user account
  <input type=text name="userId" size="18" value="" >
<br>
  The login password      
<input type="password" name="password" size="19" value=""/>     
 <input type=submit name="submit1" value=" landing "
</form

**The third: **

<script type="text/javascript">
         function check(form) {

          if(form.userId.value=='') {
                alert(" Please enter the user account !");
                form.userId.focus();
                return false;
           }
       if(form.password.value==''){
                alert(" Please enter your login password !");
                form.password.focus();
                return false;
         }

          document.myform.submit();
}
</script>
<form action="login.do?act=login" name="myform" method="post">
 The user account
  <input type=text name="userId" size="18" value="" >
<br>
  The login password      
<input type="password" name="password" size="19" value=""/>     
<input type=button name="submit1" value=" landing " onclick="check(this.form)"
</form>