hjg
2024-10-30 8cf23534166c07e711aac2a25911ada317ba01f0
提交 | 用户 | 时间
58d006 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
A 2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
5 <title>Test for jQuery validate() plugin</title>
6
7 <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
8 <script src="../lib/jquery.js" type="text/javascript"></script>
9 <script src="firebug/firebug.js" type="text/javascript"></script>
10
11 <script type="text/javascript">
12 $().ready(function() {
13     var handler = {
14         focusin: function() {
15             $(this).addClass("focus");
16         },
17         focusout: function() {
18             $(this).removeClass("focus");
19         }
20     }
21     $("#commentForm").delegate("focusin focusout", ":text, textarea", function(event) {
22         /*
23         this.addClass("focus").one("blur", function() {
24             $(this).removeClass("focus");
25         });
26         */
27         handler[event.type].call(this, arguments);
28     });
29     $("#remove").click(function() {
30         $("#commentForm").unbind("focusin");
31     })
32 });
33 </script>
34
35 <style type="text/css">
36 #commentForm { width: 500px; }
37 #commentForm label { width: 250px; display: block; float: left; }
38 #commentForm label.error, #commentForm input.submit { margin-left: 253px; }
39 .focus { background-color: red; }
40 </style>
41
42 </head>
43 <body>
44 <form class="cmxform" id="commentForm" method="get" action="">
45     <fieldset>
46         <legend>A simple comment form with submit validation and default messages</legend>
47         <p>
48             <label for="cname">Name (required, at least 2 characters)</label>
49             <input id="cname" name="name" class="some other styles {required:true,minLength:2}" />
50         <p>
51             <label for="cemail">E-Mail (required)</label>
52             <input id="cemail" name="email" class="{required:true,email:true}" />
53         </p>
54         <p>
55             <label for="curl">URL (optional)</label>
56             <input id="curl" name="url" class="{url:true}" value="" />
57         </p>
58         <p>
59             <label for="ccomment">Your comment (required)</label>
60             <textarea id="ccomment" name="comment" class="{required:true}"></textarea>
61         </p>
62         <p>
63             <input class="submit" type="submit" value="Submit"/>
64         </p>
65     </fieldset>
66 </form>
67
68 <button id="remove">Remove focus handler</button>
69
70 </body>
71 </html>