1. When you enter a username and password is empty, you need to judge. This time the user name and password used to verify, this need in the JSP front-end page write, there are two methods, one is submitted with submit. One is submitted with a button.
Method One:
Insert a JS method in the header of the front page of the JSP:
function CheckUser () {
var result = document.getElementById ("userid"). Value;
var password = document.getElementById ("Userpassid"). Value;
if (result = = "") {
Alert ("User name cannot be empty");
return false;
}
if (password = = "") {
Alert ("Password cannot be blank");
return false;
}else{
return true;
}
}
Write this in the form form:
<form id= "Formid" Name= "myform" method = ' post ' action = ' user_login_submit.action ' onsubmit = ' return CheckUser (); " >
<table width= "100%" border= "0" >
<tr>
<TD width= "height=" align= "right" > Username </td>
<td><input type= "text" value= "class=" text2 "name =" username "id =" userid "/></td>
</tr>
<tr>
<TD width= "height=" align= "right" > Secret code </td>
<td><input type= "Password" value= "class=" text2 "name =" Userpass "id =" Userpassid "/></td>
</tr>
<tr>
<TD width= "height=" align= "right" > </td>
<td><div class= "C4" >
<input type= "Submit" value= "" class= "btn2"/>
Method Two:
function CheckUser () {
var result = document.getElementById ("userid"). Value;
var password = document.getElementById ("Passid"). Value;
if (result = = "") {
Alert ("User name cannot be empty");
return false;
}
if (password = = "") {
Alert ("Password cannot be blank");
return false;
}
document.getElementById ("Formid"). Submit ();
}
Form form, you need to write ID
<form id= "Formid" method = ' post ' action = ' user_login_submit.action ' >
The button buttons are written as follows:
<input type= "button" value= "class=" btn2 "onclick =" checkUser (); "/>