Note: to verify whether the verification is null, you must first ensure that the verification is performed before the form is submitted. If there are empty items in the verification result, the form cannot be submitted and a verification error message is prompted, when the verification page property is not empty, the form is submitted normally. This part is a JS part and has nothing to do with the background business logic layer and control layer.
You can restrict the submission by using the form label or by adding the onclick event restriction on the submit button:
<Form action = ".." method = "Post"Onsubmit= "Return check ();">
<Input type = "Submit" value = "Submit"Onclick= "Return check ()">
Case:
<Form action = "./login. Action" method = "Post" onsubmit = "Return check ();">
<Table>
<Tr>
<TD width = "451"> & nbsp; </TD>
& Lt; TD width = "378" & gt;
User Name:
& nbsp; |
|
& nbsp; |
password: |
|
& nbsp; & nbsp; |
<! -- Introduce the JS file jquery -->
<SCRIPT type = "text/JavaScript" src = "JS/common/jquery-1.5.1.min.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
Function check (){
VaR username = $ ("# username"). Val ();
VaR Password = $ ("# password"). Val ();
Alert (username );
Alert (password );
If (username = ""){
$ ("# Checkusername" ).html ("<font color = 'red'> the user name cannot be blank! </Font> ");
Return false;
}
If (Password = ""){
$ ("# Checkpassword" ).html ("<font color = 'red'> the password cannot be blank! </Font> ");
Return false;
}
Return true;
}
</SCRIPT>