PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
HTML | 161 lines | 144 code | 16 blank | 1 comment | 0 complexity | 233ababb283be35baeaddcc2f49129c1 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  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. <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="../lib/jquery.metadata.js" type="text/javascript"></script>
  10. <script src="../jquery.validate.js" type="text/javascript"></script>
  11. <style type="text/css">
  12. .cmxform fieldset p.error label { color: red; }
  13. div.container {
  14. background-color: #eee;
  15. border: 1px solid red;
  16. margin: 5px;
  17. padding: 5px;
  18. }
  19. div.container ol li {
  20. list-style-type: disc;
  21. margin-left: 20px;
  22. }
  23. div.container { display: none }
  24. .container label.error {
  25. display: inline;
  26. }
  27. form.cmxform { width: 30em; }
  28. form.cmxform label.error {
  29. display: block;
  30. margin-left: 1em;
  31. width: auto;
  32. }
  33. </style>
  34. <script type="text/javascript">
  35. // only for demo purposes
  36. $.validator.setDefaults({
  37. submitHandler: function() {
  38. alert("submitted! (skipping validation for cancel button)");
  39. }
  40. });
  41. $().ready(function() {
  42. $("#form1").validate({
  43. errorLabelContainer: $("#form1 div.error")
  44. });
  45. var container = $('div.container');
  46. // validate the form when it is submitted
  47. var validator = $("#form2").validate({
  48. errorContainer: container,
  49. errorLabelContainer: $("ol", container),
  50. wrapper: 'li',
  51. meta: "validate"
  52. });
  53. $(".cancel").click(function() {
  54. validator.resetForm();
  55. });
  56. });
  57. </script>
  58. </head>
  59. <body>
  60. <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jQuery Validation Plugin</a> Demo</h1>
  61. <div id="main">
  62. <form method="get" class="cmxform" id="form1" action="">
  63. <fieldset>
  64. <legend>Login Form</legend>
  65. <p>
  66. <label>Username</label>
  67. <input name="user" title="Please enter your username (at least 3 characters)" class="{required:true,minlength:3}" />
  68. </p>
  69. <p>
  70. <label>Password</label>
  71. <input type="password" maxlength="12" name="password" title="Please enter your password, between 5 and 12 characters" class="{required:true,minlength:5}" />
  72. </p>
  73. <div class="error">
  74. </div>
  75. <p>
  76. <input class="submit" type="submit" value="Login"/>
  77. </p>
  78. </fieldset>
  79. </form>
  80. <!-- our error container -->
  81. <div class="container">
  82. <h4>There are serious errors in your form submission, please see below for details.</h4>
  83. <ol>
  84. <li><label for="email" class="error">Please enter your email address</label></li>
  85. <li><label for="phone" class="error">Please enter your phone <b>number</b> (between 2 and 8 characters)</label></li>
  86. <li><label for="address" class="error">Please enter your address (at least 3 characters)</label></li>
  87. <li><label for="avatar" class="error">Please select an image (png, jpg, jpeg, gif)</label></li>
  88. <li><label for="cv" class="error">Please select a document (doc, docx, txt, pdf)</label></li>
  89. </ol>
  90. </div>
  91. <form class="cmxform" id="form2" method="get" action="">
  92. <fieldset>
  93. <legend>Validating a complete form</legend>
  94. <p>
  95. <label for="email">Email</label>
  96. <input id="email" name="email" class="{validate:{required:true,email:true}}" />
  97. </p>
  98. <p>
  99. <label for="agree">Favorite Color</label>
  100. <select id="color" name="color" title="Please select your favorite color!" class="{validate:{required:true}}">
  101. <option></option>
  102. <option>Red</option>
  103. <option>Blue</option>
  104. <option>Yellow</option>
  105. </select>
  106. </p>
  107. <p>
  108. <label for="phone">Phone</label>
  109. <input id="phone" name="phone" class="some styles {validate:{required:true,number:true, rangelength:[2,8]}}" />
  110. </p>
  111. <p>
  112. <label for="address">Address</label>
  113. <input id="address" name="address" class="some other styles {validate:{required:true,minlength:3}}" />
  114. </p>
  115. <p>
  116. <label for="avatar">Avatar</label>
  117. <input type="file" id="avatar" name="avatar" class="{validate:{required:true,accept:true}}" />
  118. </p>
  119. <p>
  120. <label for="agree">Please agree to our policy</label>
  121. <input type="checkbox" class="checkbox" id="agree" title="Please agree to our policy!" name="agree" class="{validate:{required:true}}" />
  122. </p>
  123. <p>
  124. <label for="cv">CV</label>
  125. <input type="file" id="cv" name="cv" class="{validate:{required:true,accept:'docx?|txt|pdf'}}" />
  126. </p>
  127. <p>
  128. <input class="submit" type="submit" value="Submit"/>
  129. <input class="cancel" type="submit" value="Cancel"/>
  130. </p>
  131. </fieldset>
  132. </form>
  133. <div class="container">
  134. <h4>There are serious errors in your form submission, please see details above the form!</h4>
  135. </div>
  136. <a href="index.html">Back to main page</a>
  137. </div>
  138. <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
  139. </script>
  140. <script type="text/javascript">
  141. _uacct = "UA-2623402-1";
  142. urchinTracker();
  143. </script>
  144. </body>
  145. </html>