The first type:
The code is as follows:
<script type= "Text/javascript" >functionCheck (form) {if(form.userid.value== ") {alert ("Please enter 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" >User Account<input type=text name= "userId" size= "value=" "><br>Login Password<input type= "password" name= "password" size= "" value= ""/> <input type=submit name= "submit1" value= "Login" on click= "return check (this.form)" > </form>
The second Kind
The code is as follows:
<script type= "Text/javascript" >functionCheck (form) {if(form.userid.value== ") {alert ("Please enter 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)" >User Account<input type=text name= "userId" size= "value=" "><br>Login Password<input type= "password" name= "password" size= "" value= ""/> <input type=submit name= "submit1" value= "Login" ; </form>
The third type:
The code is as follows:
<script type= "Text/javascript" >functionCheck (form) {if(form.userid.value== ") {alert ("Please enter 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" >User Account<input type=text name= "userId" size= "value=" "><br>Login Password<input type= "password" name= "password" size= "" value= ""/> <input type=button name= "submit1" value= "Login" Onc lick= "Check (this.form)" > </form>
Three ways to summarize the form after JS check form (GO)