Demo1.html
Demo2.html<script language= "Javascript" ><!--function Submit1 (frm) { if (document.frm.word.value== "") { alert ("Please enter search news content!") ");d Ocument.frm.word.focus (); return false;} return true;} --></script><form method= "POST" action= "name=" frm "onsubmit=" return Submit1 (this); " ><select name= "Select0" > <option value= "0" > Please select a category </option><option value= "1" > News </ Option><option value= "2" > Products </option><option value= "3" > Message </option></select>< Input type= "text" name= "word" size= "class=" input "style=" HEIGHT:19PX; "><input type=" Radio "name=" Sea_cat "value=" title "> Title <input type=" Radio "name=" Sea_cat "value=" Content "> Content <input type= "Submit" value= "search" name= "B1" class= "INPUT1" >
Demo3.html<script type= "Text/javascript" >function beforesubmit (form) {if (form.username.value== ') {alert (' username cannot be empty! '); Form.username.focus (); return false;} if (form.password.value== ') {alert (' Password cannot be empty! '); Form.password.focus (); return false;} if (form.password.value.length<6) {alert (' password is at least 6 bits, please re-enter! '); Form.password.focus (); return false;} if (form.password.value!=form.password2.value) {alert (' you entered the password two times inconsistent, please re-enter! '); Form.password2.focus (); return false;} return true;} </script><fieldset> <legend> User Registration </legend> <form method= "post" name= "form" action= " User.do?method=register "onsubmit=" return Beforesubmit (this); " > <table border= "1" width= "100%" cellspacing= "0" cellpadding= "0" > <tr><td><label> User name: & Lt;input type= "text" name= "username" value= "" ></label></td></tr> <tr><td>< label> Password: <input type= "password" name= "password" value= "" ></label></td></tr> <tr>& Lt;td><label> Repeat Password: <input type= "password" name= "Password2" value= "" ></label></td></tr> <tr>& Lt;td><input value= "Registration" type= "submit" > <input type= "reset" value= "reset" ></td></tr> < /table> </form></fieldset>
JS to judge that all the form items are not empty submit the form