PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/demo/uikit/stackedForm.html

https://gitlab.com/x33n/formvalidation
HTML | 198 lines | 183 code | 15 blank | 0 comment | 0 complexity | 05423ce00ff581d5033e4dc4b03f6461 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>FormValidation &rarr; UIKit demo</title>
  7. <link rel="stylesheet" href="http://cdn.jsdelivr.net/uikit/2.13.1/css/uikit.min.css"/>
  8. <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" />
  9. <link rel="stylesheet" href="../../dist/css/formValidation.css"/>
  10. <script type="text/javascript" src="../../vendor/jquery/jquery.min.js"></script>
  11. <script type="text/javascript" src="http://cdn.jsdelivr.net/uikit/2.13.1/js/uikit.min.js"></script>
  12. <script type="text/javascript" src="../../dist/js/formValidation.js"></script>
  13. <script type="text/javascript" src="../../dist/js/framework/uikit.js"></script>
  14. <style type="text/css">
  15. body {
  16. padding: 50px 0;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div class="uk-width-1-2 uk-container-center">
  22. <form id="stackedForm" class="uk-form uk-form-stacked">
  23. <h2>UIKit Form</h2>
  24. <hr/>
  25. <div class="uk-form-row">
  26. <label class="uk-form-label">Full name</label>
  27. <div class="uk-form-controls">
  28. <input name="firstName" type="text" placeholder="First name" />
  29. </div>
  30. </div>
  31. <div class="uk-form-row">
  32. <label class="uk-form-label"></label>
  33. <div class="uk-form-controls">
  34. <input name="lastName" type="text" placeholder="Last name" />
  35. </div>
  36. </div>
  37. <div class="uk-form-row">
  38. <label class="uk-form-label">Username</label>
  39. <div class="uk-form-controls">
  40. <input name="username" type="text" placeholder="Username" />
  41. </div>
  42. </div>
  43. <div class="uk-form-row">
  44. <label class="uk-form-label">Email address</label>
  45. <div class="uk-form-controls">
  46. <input name="email" type="text" placeholder="Email address" />
  47. </div>
  48. </div>
  49. <div class="uk-form-row">
  50. <label class="uk-form-label">Password</label>
  51. <div class="uk-form-controls">
  52. <input name="password" type="password" placeholder="Password" />
  53. </div>
  54. </div>
  55. <div class="uk-form-row">
  56. <label class="uk-form-label">Gender</label>
  57. <div class="uk-form-controls">
  58. <label><input name="gender" type="radio" value="male" /> Male</label> <br/>
  59. <label><input name="gender" type="radio" value="female" /> Female</label> <br/>
  60. <label><input name="gender" type="radio" value="other" /> Other</label>
  61. </div>
  62. </div>
  63. <div class="uk-form-row">
  64. <label class="uk-form-label" id="captchaOperation"></label>
  65. <div class="uk-form-controls">
  66. <input type="text" name="captcha" />
  67. </div>
  68. </div>
  69. <div class="uk-form-row">
  70. <label class="uk-form-label"></label>
  71. <div class="uk-form-controls">
  72. <label>
  73. <input name="agree" type="checkbox" /> Agree with the terms and conditions
  74. </label>
  75. </div>
  76. </div>
  77. <div class="uk-form-row">
  78. <label class="uk-form-label"></label>
  79. <div class="uk-form-controls">
  80. <button type="submit" class="uk-button uk-button-primary">Submit</button>
  81. </div>
  82. </div>
  83. </form>
  84. </div>
  85. <script type="text/javascript">
  86. $(document).ready(function() {
  87. // Generate a simple captcha
  88. function randomNumber(min, max) {
  89. return Math.floor(Math.random() * (max - min + 1) + min);
  90. };
  91. $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
  92. $('#stackedForm').formValidation({
  93. framework: 'uikit',
  94. icon: {
  95. valid: 'fa fa-check',
  96. invalid: 'fa fa-times',
  97. validating: 'fa fa-refresh',
  98. feedback: 'fv-control-feedback'
  99. },
  100. fields: {
  101. firstName: {
  102. validators: {
  103. notEmpty: {
  104. message: 'The first name is required'
  105. }
  106. }
  107. },
  108. lastName: {
  109. validators: {
  110. notEmpty: {
  111. message: 'The last name is required'
  112. }
  113. }
  114. },
  115. username: {
  116. message: 'The username is not valid',
  117. validators: {
  118. notEmpty: {
  119. message: 'The username is required'
  120. },
  121. stringLength: {
  122. min: 6,
  123. max: 30,
  124. message: 'The username must be more than 6 and less than 30 characters long'
  125. },
  126. regexp: {
  127. regexp: /^[a-zA-Z0-9_\.]+$/,
  128. message: 'The username can only consist of alphabetical, number, dot and underscore'
  129. }
  130. }
  131. },
  132. email: {
  133. validators: {
  134. notEmpty: {
  135. message: 'The email address is required'
  136. },
  137. emailAddress: {
  138. message: 'The input is not a valid email address'
  139. }
  140. }
  141. },
  142. password: {
  143. validators: {
  144. notEmpty: {
  145. message: 'The password is required'
  146. },
  147. different: {
  148. field: 'username',
  149. message: 'The password cannot be the same as username'
  150. }
  151. }
  152. },
  153. gender: {
  154. validators: {
  155. notEmpty: {
  156. message: 'The gender is required'
  157. }
  158. }
  159. },
  160. captcha: {
  161. validators: {
  162. callback: {
  163. message: 'Wrong answer',
  164. callback: function(value, validator) {
  165. var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]);
  166. return value == sum;
  167. }
  168. }
  169. }
  170. },
  171. agree: {
  172. validators: {
  173. notEmpty: {
  174. message: 'You must agree with the terms and conditions'
  175. }
  176. }
  177. }
  178. }
  179. });
  180. });
  181. </script>
  182. </body>
  183. </html>