Objective: l master the basic process of client verification; l master the JSP output information; l master the basic usage of jstl. Main Content: l introduce the basic process of client verification through an instance; l introduce the basic methods of JSP output information; l introduce the basic usage of jstl through instance analysis. Client-side verification-related code can be seen everywhere on the network and is very common. Therefore, you do not need to write your own code, but you need to know how to use and modify it. The following describes the basic usage process: 1. How to embed Javascript code and use javasript code to complete client verification of user input information. The process of embedding JavaScript code in the page is as follows: <script language = "JavaScript"> // embed Javascript code here </SCRIPT> JavaScript code must be between the start mark and the end mark. 2. How to Write Javascript methods various verification processes exist in the form of methods. The JavaScript method is defined as follows: Function Method Name (parameter list) {// method body} is different from the method definition in Java. function declaration must define a method without the return value type. Any results can be returned. The parameter list does not need to provide the parameter type. The following is an example of a method: function validate (form ){...} The following is a method to determine whether a parameter is a number: // to determine whether the parameter is a number function isnumber (STR) {for (I = 0; I <Str. length; I ++) {// If You Want To determine the decimal point, you need to determine the decimal point if (Str. charat (I)> = '0' & Str. charat (I) <= '9' | Str. charat (I) = "-" & I = 0) continue; else return false;} return true;} 3. How to establish an association between form submission and verification methods? The onsubmit event of the form is used. <Form name = "form1" method = "Post" Action = "process. jsp" onsubmit = "Return isvalidate (form1)"> the red part calls the verification method. Note: At this time, the form submission event is used, and the submit button is used. You can also change the submit button to a normal button, and then use the onclick event of the button to call the verification method. 4. Obtain the entered information during verification. If yes? Name of the form until the form element, and then get the value. For example, userid = form. userid. value; variables can be directly used without definition. 5. instance: Verify the user name and password in the registration function <% @ page contenttype = "text/html; charset = gb2312 "%> <script language =" JavaScript "> // function isvalidate (form) {userid = form. userid. value; If (userid = "") {alert ("User ID cannot be blank"); Return false;} else if (userid. length> 8 | userid. length <6) {alert ("the length should be 6-8 digits"); Return false;} userpass = form. userpass. value; If (userpass. length! = 8) {alert ("the password length is not 8! "); Return false;} return true;} </SCRIPT> register <br> <form name =" form1 "method =" Post "Action =" process. JSP "onsubmit =" Return isvalidate (form1) "> User ID: <input type =" text "name =" userid "> the user ID is 6-8 characters long. <br> password: <input type = "password" name = "userpass"> the password length is 8 <br> confirm the password: <input type = "password" name = "userpass1"> <br> gender: <input type = "radio" name = "sex" value = "male" Checked> male <input type = "radio" name = "sex" value = "female"> female <BR> Hobbies: <input type = "checkbox" name = "fav" value = ""> motion <input type = "checkbox" name = "fav" value = "Music"> music <Input type = "checkbox" name = "fav" value = "programming"> programming <br> education level: <select name = "degree"> <option value = ""> Bachelor's Degree </option> <option value = ""> Master's Degree </option> <option value = "Emy "> specialist </option> <option value =" "> PhD </option> </SELECT> <br> remarks: <textarea name = "comment"> </textarea> <br> <input type = "Submit" value = "Submit"> <Input Type = "reset" value = "reset"> </form> 6. Common verification: Pass regiest. JSP file Introduction This verification is not the most comprehensive, and is not the best. If you need it, you can search through the network, or you can check JavaScript related books, there are many ready-made Javascript methods available. In addition, regular expressions can be used for client verification, which is convenient. The following code is for reference: <% @ page contenttype = "text/html; charset = gb2312" %> <script language = "JavaScript"> function isvalidate (form) {// obtain userid = form. userid. value; username = form. username. value; userpass = form. userpass. value; userpass2 = form. userpass2.value; Birthday = form. birthday. value; email = form. email. value; address = form. address. value; phone = form. phone. value; // determine the length of the user ID if (! Minlength (userid, 6) {alert ("the length of the user ID is less than 6 characters! "); Form. userid. Focus (); Return false;} If (! Maxlength (userid, 8) {alert ("the length of the user ID is greater than 8 characters! "); Form. userid. Focus (); Return false ;}// determine the username length if (! Minlength (username, 6) {alert ("the username length is less than 6 characters! "); Form. username. Focus (); Return false;} If (! Maxlength (username, 8) {alert ("the username length is greater than 8 characters! "); Form. username. Focus (); Return false ;}// determine the password length if (! Minlength (userpass, 6) {alert ("the password length is less than 6 characters! "); Form. userpass. Focus (); Return false;} If (! Maxlength (userpass, 8) {alert ("the password length is greater than 8 characters! "); Form. userpass. Focus (); Return false;} // determine whether the user name and password are the same if (username = userpass) {alert (" the user name and password cannot be the same! "); Form. userpass. Focus (); Return false;} // verify whether the two passwords are the same if (userpass! = Userpass2) {alert ("the two passwords are different! "); Form. userpass. Focus (); Return false ;}// verify that the birthday format is correct if (! Isdate (birthday) {alert ("the birthday format is incorrect! "); Form. Birthday. Focus (); Return false ;}// verify that the email format is correct if (! Isemail (email) {alert ("Incorrect email format! "); Form. Email. Focus (); Return false;} // verify that the phone number format is correct if (! Isdigital (phone) {alert ("Incorrect Phone Number Format"); form. phone. focus (); Return false;} // verify that the address length is correct if (! Maxlength (address, 50) {alert ("the address length is greater than 50 characters! "); Form. address. focus (); Return false;} return true;} // verify whether the function isnull (STR) {If (Str. length = 0) return true; else return false;} // verify whether the minimum length function minlength (STR, length) {If (Str. length> = length) return true; else return false;} // determines whether the maximum length of the function maxlength (STR, length) {If (Str. length <= length) return true; else return false;} // determines whether it is a digital function isdigital (STR) {for (I = 0; I <Str. Length; I ++) {// allows the use of a hyphen if (Str. charat (I)> = '0' & Str. charat (I) <= '9' | Str. charat (I) = "-" & I! = 0 & I! = Str. length-1) continue; else return false;} return true;} // determines whether it is an integer function isnumber (STR) {for (I = 0; I <Str. length; I ++) {// If You Want To determine the decimal point, you need to determine the decimal point if (Str. charat (I)> = '0' & Str. charat (I) <= '9' | Str. charat (I) = "-" & I = 0) continue; else return false;} return true;} // determines whether the date is used, the date format is 1988-1-1 function isdate (date) {// search separator index1 = date. indexof ("-"); // If the separator does not exist, it is not a valid time if (index1 =-1) return Fals E; // obtain year = date in the time. substring (0, index1); // obtain the remaining part of the time date = date. substring (index1 + 1); // find the second separator index1 = date. indexof ("-"); // if the second separator does not exist, if (index1 =-1) return false; // obtain the month = date in the time. substring (0, index1); // obtain the day = date in the time. substring (index1 + 1); // determines whether it is a number. If not, it is not a legal time. If (isnumber (year) & isnumber (month) & isnumber (day )) {// determine the basic range: If (year <1900 | year> 9999 | Mo Nth <1 | month> 12 | day <1) return false; // judge the 31-day month if (month = 1 | month = 3 | month = 5 | month = 7 | month = 8 | month = 10 | month = 12) & day> 31) return false; // determine the 30-day month if (month = 4 | month = 6 | month = 9 | month = 11) & day> 30) return false; // if it is January 1, February, judge whether it is a runner-up if (month = 2) {If (Year % 400 = 0 | (Year % 4 = 0 & year % 100! = 0) {If (day> 29) return false;} else {If (day> 28) return false ;}} else return false; return true ;} // determine whether email function isemail (email) {If (email. length = 0) return false; index1 = Email. indexof ('@'); index2 = Email. indexof ('. '); If (index1 <1 // @ symbol does not exist, or it is in the first position | index2 <1 //. the symbol does not exist or is in the first position | index2-index1 <2 //. on the left of @ or adjacent | index2 + 1 = Email. length )//. there is nothing behind the symbol return false else retu Rn true ;} </SCRIPT> <HTML>