表单

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%@taglib prefix='c' uri="http://java.sun.com/jsp/jstl/core" %>
 3 <%
 4 String path = request.getContextPath();
 5 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 6 %>
 7 
 8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 9 <html>
10   <head>
11     <base href="<%=basePath%>">
12     <title>添加花卉的信息</title>
13 
14     <script type="text/javascript" src="js/jquery-1.7.2.js"></script>          引入外部的Jquery文件
15     <script type="text/javascript">
16     //页面加载完成后执行
17     //相当于:window.onload=function(){}   $(document).ready(function(){});
18     $(function(){
19         $("form").submit(function(){
20             //表单选择器,    :input标签type属性值                                            通过jquery控制表单不为空,并弹出提示框
21             if($(":text:eq(0)").val()==""||$(":text:eq(1)").val()==""||$(":text:eq(2)").val()==""){
22                 alert("请填写完整信息");
23                 //阻止默认行为
24                 return false;                                    只要使用这个方法,就会指定表单提25             }
26         });
27     });
28     </script>
29   </head>
30   
31   <body>
32  <form action = "insert" method="post">
33       <table border="1" align="center">
34           <tr>
35               <td colspan="2" style="text-align:center;font-size:30px;font-weight:bold;">
36                   花卉信息
37               </td>
38           </tr>
39           <tr>
40               <td><b>花卉名称</b></td>
41               <td><input type="text" name="name"/></td>
42           </tr>
43           </tr>
44           <tr>
45               <td><b>花卉价格</b></td>
46               <td><input type="text" name="price"/></td>
47           </tr>
48           <tr>
49               <td><b>原产地</b></td>
50               <td><input type="text" name="production"/></td>
51           </tr>
52           <tr>
53               <td colspan="2" align="center">
54                   <input type="submit" value="提交"/><input type="reset" value="重置"/>
55               </td>
56           </tr>
57                     
58       
59       </table>
60  </form>
61   </body>
62 </html>
好好学习,天天向上。 努力工作,给自己的和家人一个满意的答案。。。。
原文地址:https://www.cnblogs.com/axu521/p/10053048.html