PluginProbe
RSVP and Event Management / 1.3.0
RSVP and Event Management v1.3.0
trunk 0.5.0 0.6.0 0.7.0 0.8.0 0.9.0 0.9.5 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.5.0 1.6.0 1.6.1 1.6.2 1.6.5 1.7.0 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 All 136 releases
rsvp / jquery-validate / demo / custom-methods-demo.html

custom-methods-demo.html in RSVP and Event Management 1.3.0, at jquery-validate/demo/custom-methods-demo.html

123 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?xml version="1.0" encoding="ISO-8859-1" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
6 <title>Test for jQuery validate() plugin</title>
7
8 <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
9
10 <script src="../lib/jquery.js" type="text/javascript"></script>
11 <script src="../jquery.validate.js" type="text/javascript"></script>
12
13 <script src="js/cmxforms.js" type="text/javascript"></script>
14 <script type="text/javascript">
15 // extend the current rules with new groovy ones
16
17 // this one requires the text "buga", we define a default message, too
18 $.validator.addMethod("buga", function(value) {
19 return value == "buga";
20 }, 'Please enter "buga"!');
21
22 // this one requires the value to be the same as the first parameter
23 $.validator.methods.equal = function(value, element, param) {
24 return value == param;
25 };
26
27 $().ready(function() {
28 var validator = $("#texttests").bind("invalid-form.validate", function() {
29 $("#summary").html("Your form contains " + validator.numberOfInvalids() + " errors, see details below.");
30 }).validate({
31 debug: true,
32 errorElement: "em",
33 errorContainer: $("#warning, #summary"),
34 errorPlacement: function(error, element) {
35 error.appendTo( element.parent("td").next("td") );
36 },
37 success: function(label) {
38 label.text("ok!").addClass("success");
39 },
40 rules: {
41 number: {
42 required:true,
43 minLength:3,
44 maxLength:15,
45 number:true
46 },
47 secret: "buga",
48 math: {
49 equal: 11
50 }
51 }
52 });
53
54 });
55 </script>
56
57 <style type="text/css">
58 form.cmxform { width: 50em; }
59 em.error {
60 background:url("images/unchecked.gif") no-repeat 0px 0px;
61 padding-left: 16px;
62 }
63 em.success {
64 background:url("images/checked.gif") no-repeat 0px 0px;
65 padding-left: 16px;
66 }
67
68 form.cmxform label.error {
69 margin-left: auto;
70 width: 250px;
71 }
72 em.error { color: black; }
73 #warning { display: none; }
74 </style>
75
76 </head>
77 <body>
78
79 <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jQuery Validation Plugin</a> Demo</h1>
80 <div id="main">
81
82 <form class="cmxform" id="texttests" method="get" action="foo.html">
83 <h2 id="summary"></h2>
84
85 <fieldset>
86 <legend>Example with custom methods and heavily customized error display</legend>
87 <table>
88 <tr>
89 <td><label for="number">textarea</label></td>
90 <td><input id="number" name="number"
91 title="Please enter a number with at least 3 and max 15 characters!" />
92 </td>
93 <td></td>
94 </tr>
95 <tr>
96 <td><label for="secret">Secret</label></td>
97 <td><input name="secret" id="secret" /></td>
98 <td></td>
99 </tr>
100 <tr>
101 <td><label for="math">7 + 4 = </label></td>
102 <td><input id="math" name="math" title="Please enter the correct result!" /></td>
103 <td></td>
104 </tr>
105 </table>
106 <input class="submit" type="submit" value="Submit"/>
107 </fieldset>
108 </form>
109
110 <h3 id="warning">Your form contains tons of errors! Please try again.</h3>
111
112 <p><a href="index.html">Back to main page</a></p>
113
114 </div>
115
116 <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
117 </script>
118 <script type="text/javascript">
119 _uacct = "UA-2623402-1";
120 urchinTracker();
121 </script>
122 </body>
123 </html>