In many cases, we do not fill in all the information in one step, and then submit it. Instead, enter the form step by step, as shown below:
Step 1 fill in the basic information,
Step 2 fill in the Education Information
Verification is required for each step, so that verification can be performed in the following ways:
<SCRIPT type = "text/JavaScript" Language = "JavaScript" src = "http://www.cnblogs.com/Scripts/jquery-1.4.1.min.js"> </SCRIPT> <SCRIPT type = "text/JavaScript" Language = "JavaScript" src = "http://www.cnblogs.com/Scripts/jquery.validate.min.js"> </SCRIPT> <H2> validatestep </H2> <form action = "" id = "registerform" method = "Post"> <Div class = "Step1 validationgroup "Style =" display: block; "> <p> Basic Information </P> <Table border = "0" cellpadding = "0" cellspacing = "0"> <tr> <TD> Name: <input type = "text" id = "name" class = "required"/> </TD> </tr> <TD> age: <input type = "text" id = "Age" class = "Required number"/> </TD> </tr> <TD> <input type = "button "Class =" Next "value =" Next "/> </TD> </tr> </table> </div> <Div class =" step2 validationgroup "style =" display: none "> <p> educational background </P> <Table border =" 0 "cellpadding =" 0 "cellspacing =" 0 "> <Tr> <TD> graduation school: <input type = "text" id = "school" class = "required"/> </TD> </tr> <TD> Major: <input type = "text" id = "Major" class = "required"/> </TD> </tr> <TD> <input type = "Submit" value = "Submit"/> </TD> </tr> </table> </div> </form> <script language = "JavaScript" type = "text/JavaScript "> function initvalidationgroup () {$ ('. validationgroup. next '). click (function (EVT) {If (isvalidated ($ (this ). clo SEST (". validationgroup ") {$ (". step 1 "). hide (); $ (". step 2 "). show ();} else {EVT. preventdefault () ;}}); $ ('. step 1: text '). keydown (function (EVT) {If (EVT. keycode = 13) {var $ nextinput = $ (this ). nextall (': input: First'); if ($ nextinput. is (': Submit') {validate (EVT);} else {EVT. preventdefault (); $ nextinput. focus () ;}}) ;}function isvalidated (Group) {var isvalid = true; group. find (': Input '). Each (function (I, item) {If (! $ (Item ). valid () isvalid = false ;}); return isvalid ;}$ (document ). ready (function () {initvalidationgroup (); var validator = $ ("# registerform "). validate () ;}); </SCRIPT>
Here, we mainly use the valid () and isvalid methods in jquery validate, which is very simple.