這個是js
1 <script type="text/javascript">
2 function checkForm(){
3 var section = document.getElementById('section').value;
4 var page = document.getElementById('page').value;
5 if (section==""){
6 alert("請輸入章節");
7 return false;
8 }
9 else if(page==""){
10 alert("請輸入頁碼");
11 return false;
12 }
13 myform.submit();
14 }
15 </script>
這個是表單
1 <form name="myform" action="searchBySectionAndPage.do" mothd="post">
2 <table>
3 <tr>
4 <td>
5 章節
6 </td>
7 <td>
8 <input type="text" name="section">
9 </td>
10 </tr>
11 <tr>
12 <td>
13 頁碼
14 </td>
15 <td>
16 <input type="text" name="page">
17 </td>
18 </tr>
19 <tr>
20 <td>
21 <input type="reset" value="重置">
22 </td>
23 <td>
24 <input type="button" value="確定" onclick="return checkForm();">
25 </td>
26 </tr>
27 </table>
28 </form>
js很讓我頭痛,備注一下.