PageRenderTime 47ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/jquery-validate/demo/themerollered.html

#
HTML | 227 lines | 210 code | 17 blank | 0 comment | 0 complexity | 67de8d30b94377251e50e1761f6a10db MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  5. <title>jQuery validation plug-in - main demo</title>
  6. <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/cupertino/jquery-ui.css" />
  7. <link rel="stylesheet" type="text/css" media="screen" href="http://jquery-ui.googlecode.com/svn/branches/dev/themes/base/ui.button.css" />
  8. <script src="../lib/jquery.js" type="text/javascript"></script>
  9. <script src="../jquery.validate.js" type="text/javascript"></script>
  10. <script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.ui.core.js" type="text/javascript"></script>
  11. <script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.ui.widget.js" type="text/javascript"></script>
  12. <script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.ui.button.js" type="text/javascript"></script>
  13. <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
  14. <script type="text/javascript">
  15. $.validator.setDefaults({
  16. submitHandler: function() { alert("submitted!"); },
  17. highlight: function(input) {
  18. $(input).addClass("ui-state-highlight");
  19. },
  20. unhighlight: function(input) {
  21. $(input).removeClass("ui-state-highlight");
  22. }
  23. });
  24. $().ready(function() {
  25. $.fn.themeswitcher && $('<div/>').css({
  26. position: "absolute",
  27. right: 10,
  28. top: 10
  29. }).appendTo(document.body).themeswitcher();
  30. // validate the comment form when it is submitted
  31. $("#commentForm").validate();
  32. // validate signup form on keyup and submit
  33. $("#signupForm").validate({
  34. rules: {
  35. firstname: "required",
  36. lastname: "required",
  37. username: {
  38. required: true,
  39. minlength: 2
  40. },
  41. password: {
  42. required: true,
  43. minlength: 5
  44. },
  45. confirm_password: {
  46. required: true,
  47. minlength: 5,
  48. equalTo: "#password"
  49. },
  50. email: {
  51. required: true,
  52. email: true
  53. },
  54. topic: {
  55. required: "#newsletter:checked",
  56. minlength: 2
  57. },
  58. agree: "required"
  59. },
  60. messages: {
  61. firstname: "Please enter your firstname",
  62. lastname: "Please enter your lastname",
  63. username: {
  64. required: "Please enter a username",
  65. minlength: "Your username must consist of at least 2 characters"
  66. },
  67. password: {
  68. required: "Please provide a password",
  69. minlength: "Your password must be at least 5 characters long"
  70. },
  71. confirm_password: {
  72. required: "Please provide a password",
  73. minlength: "Your password must be at least 5 characters long",
  74. equalTo: "Please enter the same password as above"
  75. },
  76. email: "Please enter a valid email address",
  77. agree: "Please accept our policy"
  78. }
  79. });
  80. // propose username by combining first- and lastname
  81. $("#username").focus(function() {
  82. var firstname = $("#firstname").val();
  83. var lastname = $("#lastname").val();
  84. if(firstname && lastname && !this.value) {
  85. this.value = firstname + "." + lastname;
  86. }
  87. });
  88. //code to hide topic selection, disable for demo
  89. var newsletter = $("#newsletter");
  90. // newsletter topics are optional, hide at first
  91. var inital = newsletter.is(":checked");
  92. var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
  93. var topicInputs = topics.find("input").attr("disabled", !inital);
  94. // show when newsletter is checked
  95. newsletter.click(function() {
  96. topics[this.checked ? "removeClass" : "addClass"]("gray");
  97. topicInputs.attr("disabled", !this.checked);
  98. });
  99. $("#signupForm input:not(:submit)").addClass("ui-widget-content");
  100. $(":submit").button();
  101. });
  102. </script>
  103. <style type="text/css">
  104. body { font-size: 62.5%; }
  105. label { display: inline-block; width: 100px; }
  106. legend { padding: 0.5em; }
  107. fieldset fieldset label { display: block; }
  108. #commentForm { width: 500px; }
  109. #commentForm label { width: 250px; }
  110. #commentForm label.error, #commentForm button.submit { margin-left: 253px; }
  111. #signupForm { width: 670px; }
  112. #signupForm label.error {
  113. margin-left: 10px;
  114. width: auto;
  115. display: inline;
  116. }
  117. #newsletter_topics label.error {
  118. display: none;
  119. margin-left: 103px;
  120. }
  121. </style>
  122. </head>
  123. <body>
  124. <form class="cmxform" id="commentForm" method="get" action="">
  125. <fieldset class="ui-widget ui-widget-content ui-corner-all">
  126. <legend class="ui-widget ui-widget-header ui-corner-all">Please provide your name, email address (won't be published) and a comment</legend>
  127. <p>
  128. <label for="cname">Name (required, at least 2 characters)</label>
  129. <input id="cname" name="name" class="required ui-widget-content" minlength="2" />
  130. <p>
  131. <label for="cemail">E-Mail (required)</label>
  132. <input id="cemail" name="email" class="required email ui-widget-content" />
  133. </p>
  134. <p>
  135. <label for="curl">URL (optional)</label>
  136. <input id="curl" name="url" class="url ui-widget-content" value="" />
  137. </p>
  138. <p>
  139. <label for="ccomment">Your comment (required)</label>
  140. <textarea id="ccomment" name="comment" class="required ui-widget-content"></textarea>
  141. </p>
  142. <p>
  143. <button class="submit" type="submit">Submit</button>
  144. </p>
  145. </fieldset>
  146. </form>
  147. <form class="cmxform" id="signupForm" method="get" action="">
  148. <fieldset class="ui-widget ui-widget-content ui-corner-all">
  149. <legend class="ui-widget ui-widget-header ui-corner-all">Validating a complete form</legend>
  150. <p>
  151. <label for="firstname">Firstname</label>
  152. <input id="firstname" name="firstname" />
  153. </p>
  154. <p>
  155. <label for="lastname">Lastname</label>
  156. <input id="lastname" name="lastname" />
  157. </p>
  158. <p>
  159. <label for="username">Username</label>
  160. <input id="username" name="username" />
  161. </p>
  162. <p>
  163. <label for="password">Password</label>
  164. <input id="password" name="password" type="password" />
  165. </p>
  166. <p>
  167. <label for="confirm_password">Confirm password</label>
  168. <input id="confirm_password" name="confirm_password" type="password" />
  169. </p>
  170. <p>
  171. <label for="email">Email</label>
  172. <input id="email" name="email" />
  173. </p>
  174. <p>
  175. <label for="agree">Please agree to our policy</label>
  176. <input type="checkbox" class="checkbox" id="agree" name="agree" />
  177. </p>
  178. <p>
  179. <label for="newsletter">I'd like to receive the newsletter</label>
  180. <input type="checkbox" class="checkbox" id="newsletter" name="newsletter" />
  181. </p>
  182. <fieldset id="newsletter_topics" class="ui-widget-content ui-corner-all">
  183. <legend class="ui-widget-header ui-corner-all">Topics (select at least two) - note: would be hidden when newsletter isn't selected, but is visible here for the demo</legend>
  184. <label for="topic_marketflash">
  185. <input type="checkbox" id="topic_marketflash" value="marketflash" name="topic" />
  186. Marketflash
  187. </label>
  188. <label for="topic_fuzz">
  189. <input type="checkbox" id="topic_fuzz" value="fuzz" name="topic" />
  190. Latest fuzz
  191. </label>
  192. <label for="topic_digester">
  193. <input type="checkbox" id="topic_digester" value="digester" name="topic" />
  194. Mailing list digester
  195. </label>
  196. <label for="topic" class="error">Please select at least two topics you'd like to receive.</label>
  197. </fieldset>
  198. <p>
  199. <button class="submit" type="submit">Submit</button>
  200. </p>
  201. </fieldset>
  202. </form>
  203. <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
  204. </script>
  205. <script type="text/javascript">
  206. _uacct = "UA-2623402-1";
  207. urchinTracker();
  208. </script>
  209. </body>
  210. </html>