form before submitting, we usually validate its content with client JS, usually by writing a function and then invoking it in the Onsumbit event, as follows:
The following are the referenced contents: <script language= "JavaScript" > function Check () { if (Form1.aaa.value = = "") {return false;} if (Form1.bbb.value = = "") {return false;} return true; } </script> <body> <form id= "Form1" Name= "Form1" "method=" Post "action=" Default.asp "onsubmit=" return check (); " > <p> <input name= "AAA" type= "text" id= "AAA"/> </p> <p> <input name= "BBB" type= "text" id= "BBB"/> </p> <p> <input type= "Submit" name= "Submission" value= "submitted"/> </p> </form> </body>
|
If you are using multiple functions to verify the form, how to write the function, how to call it? In fact, it is also very simple, the following example:
The following are the referenced contents: <script language= "JavaScript" > function Check1 () { if (Form1.aaa.value = "") { return false; }else{ return true; } } function Check2 () { if (Form1.bbb.value = "") { return false; }else{ return true; } } </script>
<body> <form id= "Form1" Name= "Form1" "method=" Post "action=" Default.asp "onsubmit=" Return (Check1 () && Check2 ()); " > <p> <input name= "AAA" type= "text" id= "AAA"/> </p> <p> <input name= "BBB" type= "text" id= "BBB"/> </p> <p> <input type= "Submit" name= "Submission" value= "submitted"/> </p> </form> </body>
|
Original:http://www.mzwu.com/article.asp?id=1078