input.html
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<script language="javascript"> function validate(f){ if(!(/w+/.test(f.info.value))){//正则表达式 alert("输入的内容不能为空!"); f.info.focus(); return false; } return true; } </script> This is my HTML page. <br> <FORM METHOD = "Post" action = "INPUT.jsp" onSubmit="return validate(this)"> 输入信息:<input type = "text" name = "info"> <input type = "submit" value ="info"> </FORM> <br> <script> function check(f){ if(!(/^d+$/.test(f.rows.value))){ alert("行数必须是数字"); return false; } if(!(/d+/.test(f.cols.value))){ alert("列数必须是数字"); return false; } return true; } </script> <hr> <form action="printTable.jsp" method="post" onSubmit="return check(this)"> <table border="0"> <tr> <td colspan="2">"打印表格"</td> </tr> <tr><td>输入打印表格的行数</td> <td><input type="Text" name="rows"></td> </tr> <tr><td>输入打印表格的列 数</td> <td><input type="Text" name="cols"></td> </tr> <tr> <td colspan="2"> <input type ="submit" value="打印"> <input type="reset" value="重置"> </td> </tr> </form>
printTable.jsp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<script language="javascript"> function validate(f){ if(!(/w+/.test(f.info.value))){//正则表达式 alert("输入的内容不能为空!"); f.info.focus(); return false; } return true; } </script> This is my HTML page. <br> <FORM METHOD = "Post" action = "INPUT.jsp" onSubmit="return validate(this)"> 输入信息:<input type = "text" name = "info"> <input type = "submit" value ="info"> </FORM> <br> <script> function check(f){ if(!(/^d+$/.test(f.rows.value))){ alert("行数必须是数字"); return false; } if(!(/d+/.test(f.cols.value))){ alert("列数必须是数字"); return false; } return true; } </script> <hr> <form action="printTable.jsp" method="post" onSubmit="return check(this)"> <table border="0"> <tr> <td colspan="2">"打印表格"</td> </tr> <tr><td>输入打印表格的行数</td> <td><input type="Text" name="rows"></td> </tr> <tr><td>输入打印表格的列 数</td> <td><input type="Text" name="cols"></td> </tr> <tr> <td colspan="2"> <input type ="submit" value="打印"> <input type="reset" value="重置"> </td> </tr> </form>