all.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Bootstrap Validate demo</title>
  5. <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
  6. <!--[if IE 7]>
  7. <link rel="stylesheet" href="../vendor/font-awesome/css/font-awesome-ie7.min.css">
  8. <![endif]-->
  9. <link rel="stylesheet" href="../vendor/font-awesome/css/font-awesome.min.css"/>
  10. <script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
  11. <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
  12. <script type="text/javascript" src="../dist/js/bootstrapvalidate.js"></script>
  13. </head>
  14. <body>
  15. <div class="container">
  16. <div class="row">
  17. <!-- form: -->
  18. <section>
  19. <div class="page-header">
  20. <h1>Bootstrap Validate plugin</h1>
  21. </div>
  22. <div class="col-lg-8 col-lg-offset-2">
  23. <form id="defaultForm" method="post" class="form-horizontal">
  24. <fieldset>
  25. <legend>Not Empty validator</legend>
  26. <div class="form-group">
  27. <label class="col-lg-3 control-label">Username</label>
  28. <div class="col-lg-9">
  29. <input type="text" class="form-control" name="username" />
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <div class="col-lg-9 col-lg-offset-3">
  34. <div class="checkbox">
  35. <input type="checkbox" name="acceptTerms" /> Accept the terms and policies
  36. </div>
  37. </div>
  38. </div>
  39. </fieldset>
  40. <fieldset>
  41. <legend>Regular expression based validators</legend>
  42. <div class="form-group">
  43. <label class="col-lg-3 control-label">Email address</label>
  44. <div class="col-lg-5">
  45. <input type="text" class="form-control" name="email" />
  46. </div>
  47. </div>
  48. <div class="form-group">
  49. <label class="col-lg-3 control-label">Website</label>
  50. <div class="col-lg-5">
  51. <input type="text" class="form-control" name="website" placeholder="http://" />
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <label class="col-lg-3 control-label">Phone number</label>
  56. <div class="col-lg-5">
  57. <input type="text" class="form-control" name="phoneNumber" />
  58. </div>
  59. </div>
  60. </fieldset>
  61. <fieldset>
  62. <legend>Other validators</legend>
  63. <div class="form-group">
  64. <label class="col-lg-3 control-label">Ages</label>
  65. <div class="col-lg-3">
  66. <input type="text" class="form-control" name="ages" />
  67. </div>
  68. </div>
  69. </fieldset>
  70. <fieldset>
  71. <legend>Identical validator</legend>
  72. <div class="form-group">
  73. <label class="col-lg-3 control-label">Password</label>
  74. <div class="col-lg-5">
  75. <input type="password" class="form-control" name="password" />
  76. </div>
  77. </div>
  78. <div class="form-group">
  79. <label class="col-lg-3 control-label">Retype password</label>
  80. <div class="col-lg-5">
  81. <input type="password" class="form-control" name="confirmPassword" />
  82. </div>
  83. </div>
  84. </fieldset>
  85. <div class="form-group">
  86. <div class="col-lg-9 col-lg-offset-3">
  87. <button type="submit" class="btn btn-primary">Sign up</button>
  88. </div>
  89. </div>
  90. </form>
  91. </div>
  92. </section>
  93. <!-- :form -->
  94. </div>
  95. </div>
  96. <script type="text/javascript">
  97. $(document).ready(function() {
  98. $('#defaultForm').bootstrapValidate({
  99. fields: {
  100. username: {
  101. message: 'The username is not valid',
  102. validator: {
  103. notEmpty: {
  104. message: 'The username is required and can\'t be empty'
  105. },
  106. stringLength: {
  107. min: 6,
  108. max: 30,
  109. message: 'The username must be more than 6 and less than 30 characters long'
  110. },
  111. regexp: {
  112. regexp: /^[a-zA-Z0-9_\.]+$/,
  113. message: 'The username can only consist of alphabetical, number, dot and underscore'
  114. }
  115. }
  116. },
  117. acceptTerms: {
  118. validator: {
  119. notEmpty: {
  120. message: 'You have to accept the terms and policies'
  121. }
  122. }
  123. },
  124. email: {
  125. validator: {
  126. notEmpty: {
  127. message: 'The email address is required and can\'t be empty'
  128. },
  129. emailAddress: {
  130. message: 'The input is not a valid email address'
  131. }
  132. }
  133. },
  134. website: {
  135. validator: {
  136. uri: {
  137. message: 'The input is not a valid URL'
  138. }
  139. }
  140. },
  141. phoneNumber: {
  142. validator: {
  143. digits: {
  144. message: 'The value can contain only digits'
  145. }
  146. }
  147. },
  148. password: {
  149. validator: {
  150. notEmpty: {
  151. message: 'The password is required and can\'t be empty'
  152. },
  153. identical: {
  154. field: 'confirmPassword',
  155. message: 'The password and its confirm are not the same'
  156. }
  157. }
  158. },
  159. confirmPassword: {
  160. validator: {
  161. notEmpty: {
  162. message: 'The confirm password is required and can\'t be empty'
  163. },
  164. identical: {
  165. field: 'password',
  166. message: 'The password and its confirm are not the same'
  167. }
  168. }
  169. },
  170. ages: {
  171. validator: {
  172. lessThan: {
  173. value: 100,
  174. inclusive: true,
  175. message: 'The ages has to be less than 100'
  176. },
  177. greaterThan: {
  178. value: 10,
  179. inclusive: false,
  180. message: 'The ages has to be greater than or equals to 10'
  181. }
  182. }
  183. }
  184. },
  185. message: 'This value is not valid',
  186. iconClass: {
  187. valid: 'icon-ok',
  188. invalid: 'icon-remove'
  189. }
  190. });
  191. });
  192. </script>
  193. </body>
  194. </html>