PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/jquery-validate/demo/tabs/index.html

#
HTML | 157 lines | 144 code | 13 blank | 0 comment | 0 complexity | ea2acf7a5d1e9aa905b71c8047bff4ea 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=UTF-8" />
  5. <title>jQuery UI tabs integration demo</title>
  6. <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css" />
  7. <script src="../../lib/jquery.js" type="text/javascript"></script>
  8. <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js" type="text/javascript"></script>
  9. <script src="../../jquery.validate.js" type="text/javascript"></script>
  10. <script id="demo" type="text/javascript">
  11. $(document).ready(function() {
  12. var tabs = $("#tabs").tabs();
  13. var validator = $("#signupform").validate({
  14. groups: {
  15. birthdate: "birthdateDay birthdateMonth birthdateYear"
  16. },
  17. errorPlacement: function(label, element) {
  18. if (/^birthdate/.test(element[0].name)) {
  19. label.insertAfter("#birthdateYear");
  20. } else {
  21. label.insertAfter(element);
  22. }
  23. }
  24. });
  25. // validate the other two selects when one changes to update the whole group
  26. var birthdaySelects = $("#birthdateGroup select").click(function() {
  27. birthdaySelects.not(this).valid();
  28. })
  29. // overwrite focusInvalid to activate tab with invalid elements
  30. validator.focusInvalid = function() {
  31. if( this.settings.focusInvalid ) {
  32. try {
  33. var focused = $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible");
  34. tabs.tabs("select", tabs.find(">div").index(focused.parent().parent()));
  35. focused.focus();
  36. } catch(e) {
  37. // ignore IE throwing errors when focusing hidden elements
  38. }
  39. }
  40. };
  41. });
  42. </script>
  43. <style>
  44. body { font-size: 65.2% }
  45. label { display: inline-block; width: 8em; }
  46. label.error { color: red; margin-left: 0.5em; width: 20em; }
  47. </style>
  48. </head>
  49. <body>
  50. <form id="signupform">
  51. <div id="tabs">
  52. <ul>
  53. <li><a href="#logindata">Login data</a></li>
  54. <li><a href="#personaldata">Personal data</a></li>
  55. <li><a href="#subscriptions">Subscriptions</a></li>
  56. </ul>
  57. <div id="logindata">
  58. <p>
  59. <label for="username">Username</label>
  60. <input id="username" name="username" class="required" minlength="3" maxlength="20" type="text" />
  61. </p>
  62. <p>
  63. <label for="email">Email address</label>
  64. <input id="email" name="email" class="required email" type="text" />
  65. </p>
  66. <p>
  67. <label for="password">Password</label>
  68. <input name="password" type="password" class="required" id="password" minlength="4" maxlength="50" />
  69. </p>
  70. <p>
  71. <label for="confirmpassword">Confirm Password</label>
  72. <input name="confirmpassword" type="password" class="required" equalTo="#password" id="confirmpassword" />
  73. </p>
  74. </div>
  75. <div id="personaldata">
  76. <p>
  77. <label for="street">Street</label>
  78. <input id="street" name="street" class="required" minlength="3" maxlength="50" type="text" />
  79. </p>
  80. <p>
  81. <label for="city">City</label>
  82. <input id="city" name="city" class="required" minlength="3" maxlength="50" type="text" />
  83. </p>
  84. <p id="birthdateGroup">
  85. <label for="birthdateDay">Birthdate</label>
  86. <select id="birthdateDay" name="birthdateDay" class="required">
  87. <option value="">Day</option>
  88. <option>1</option>
  89. <option>2</option>
  90. <option>3</option>
  91. <option>...</option>
  92. </select>
  93. <select id="birthdateMonth" name="birthdateMonth" class="required">
  94. <option value="">Month</option>
  95. <option>1</option>
  96. <option>2</option>
  97. <option>3</option>
  98. <option>4</option>
  99. <option>5</option>
  100. <option>6</option>
  101. <option>7</option>
  102. <option>8</option>
  103. <option>9</option>
  104. <option>10</option>
  105. <option>11</option>
  106. <option>12</option>
  107. </select>
  108. <select id="birthdateYear" name="birthdateYear" class="required">
  109. <option value="">Year</option>
  110. <option>1950</option>
  111. <option>1951</option>
  112. <option>1952</option>
  113. <option>1953</option>
  114. <option>1954</option>
  115. <option>1955</option>
  116. <option>...</option>
  117. </select>
  118. </p>
  119. </div>
  120. <div id="subscriptions">
  121. <p>
  122. <label for="weekly">Weekly Newsletter</label>
  123. <input id="weekly" name="weekly" type="checkbox" />
  124. </p>
  125. <p>
  126. <label for="updates">Product Updates</label>
  127. <input id="updates" name="updates" type="checkbox" />
  128. </p>
  129. <p>
  130. <label for="terms">Terms and conditions</label>
  131. <input id="terms" name="terms" class="required" type="checkbox" />
  132. </p>
  133. </div>
  134. </div>
  135. <input type="submit" />
  136. </form>
  137. <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
  138. </script>
  139. <script type="text/javascript">
  140. _uacct = "UA-2623402-1";
  141. urchinTracker();
  142. </script>
  143. </body>
  144. </html>