This article is excerpted from page 8-60 of Java Web development tutorial-getting started and improving (JSP + servlet. The following is an example of client verification. For more information about the Page code, see
Java Web basics: 11th basic form elements, Call the verification method code reference
Java Web basics: 12th use of Form Elements. Function isvalidate (form) {// obtain the user input 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, 2) {alert ("the length of the user name is less than 2 Characters! "); Form. username. Focus (); Return false;} If (! Maxlength (username, 10) {alert ("the username length is greater than 10 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 ID and password are the same if (userid = userpass) {alert (" the user ID 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;} after being verified by the client, the information can be submitted to the server. How does the server receive and process the information? Please refer to the next explanation. Last Lecture:
Lecture 2
Regular ExpressionNext Lecture:
17th business processing OverviewLi xucheng csdn blog: Why? U= 124362 & C = 7be8ba2b6f3b6cc5