i18n.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>BootstrapValidator demo</title>
  5. <link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
  6. <link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>
  7. <!-- Include the FontAwesome CSS if you want to use feedback icons provided by FontAwesome -->
  8. <!--<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" />-->
  9. <script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
  10. <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
  11. <script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
  12. </head>
  13. <body>
  14. <div class="container">
  15. <div class="row">
  16. <!-- form: -->
  17. <section>
  18. <div class="col-lg-8 col-lg-offset-2">
  19. <div class="page-header">
  20. <h2>Sign up</h2>
  21. </div>
  22. <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
  23. <div class="form-group">
  24. <label class="col-lg-3 control-label">Full name</label>
  25. <div class="col-lg-4">
  26. <input type="text" class="form-control" name="firstName" placeholder="First name" />
  27. </div>
  28. <div class="col-lg-4">
  29. <input type="text" class="form-control" name="lastName" placeholder="Last name" />
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <label class="col-lg-3 control-label">Username</label>
  34. <div class="col-lg-5">
  35. <input type="text" class="form-control" name="username" />
  36. </div>
  37. </div>
  38. <div class="form-group">
  39. <label class="col-lg-3 control-label">Email address</label>
  40. <div class="col-lg-5">
  41. <input type="text" class="form-control" name="email" />
  42. </div>
  43. </div>
  44. <div class="form-group">
  45. <label class="col-lg-3 control-label">Password</label>
  46. <div class="col-lg-5">
  47. <input type="password" class="form-control" name="password" />
  48. </div>
  49. </div>
  50. <div class="form-group">
  51. <label class="col-lg-3 control-label">Retype password</label>
  52. <div class="col-lg-5">
  53. <input type="password" class="form-control" name="confirmPassword" />
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <label class="col-lg-3 control-label">Gender</label>
  58. <div class="col-lg-5">
  59. <div class="radio">
  60. <label>
  61. <input type="radio" name="gender" value="male" /> Male
  62. </label>
  63. </div>
  64. <div class="radio">
  65. <label>
  66. <input type="radio" name="gender" value="female" /> Female
  67. </label>
  68. </div>
  69. <div class="radio">
  70. <label>
  71. <input type="radio" name="gender" value="other" /> Other
  72. </label>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-lg-3 control-label">Birthday</label>
  78. <div class="col-lg-5">
  79. <input type="text" class="form-control" name="birthday" /> (YYYY/MM/DD)
  80. </div>
  81. </div>
  82. <div class="form-group">
  83. <label class="col-lg-3 control-label">Languages</label>
  84. <div class="col-lg-5">
  85. <div class="checkbox">
  86. <label>
  87. <input type="checkbox" name="languages[]" value="english" /> English
  88. </label>
  89. </div>
  90. <div class="checkbox">
  91. <label>
  92. <input type="checkbox" name="languages[]" value="french" /> French
  93. </label>
  94. </div>
  95. <div class="checkbox">
  96. <label>
  97. <input type="checkbox" name="languages[]" value="german" /> German
  98. </label>
  99. </div>
  100. <div class="checkbox">
  101. <label>
  102. <input type="checkbox" name="languages[]" value="russian" /> Russian
  103. </label>
  104. </div>
  105. <div class="checkbox">
  106. <label>
  107. <input type="checkbox" name="languages[]" value="other" /> Other
  108. </label>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="form-group">
  113. <label class="col-lg-3 control-label">Programming Languages</label>
  114. <div class="col-lg-5">
  115. <div class="checkbox">
  116. <label>
  117. <input type="checkbox" name="programs[]" value="net" /> .Net
  118. </label>
  119. </div>
  120. <div class="checkbox">
  121. <label>
  122. <input type="checkbox" name="programs[]" value="java" /> Java
  123. </label>
  124. </div>
  125. <div class="checkbox">
  126. <label>
  127. <input type="checkbox" name="programs[]" value="c" /> C/C++
  128. </label>
  129. </div>
  130. <div class="checkbox">
  131. <label>
  132. <input type="checkbox" name="programs[]" value="php" /> PHP
  133. </label>
  134. </div>
  135. <div class="checkbox">
  136. <label>
  137. <input type="checkbox" name="programs[]" value="perl" /> Perl
  138. </label>
  139. </div>
  140. <div class="checkbox">
  141. <label>
  142. <input type="checkbox" name="programs[]" value="ruby" /> Ruby
  143. </label>
  144. </div>
  145. <div class="checkbox">
  146. <label>
  147. <input type="checkbox" name="programs[]" value="python" /> Python
  148. </label>
  149. </div>
  150. <div class="checkbox">
  151. <label>
  152. <input type="checkbox" name="programs[]" value="javascript" /> Javascript
  153. </label>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="form-group">
  158. <label class="col-lg-3 control-label" id="captchaOperation"></label>
  159. <div class="col-lg-2">
  160. <input type="text" class="form-control" name="captcha" />
  161. </div>
  162. </div>
  163. <div class="form-group">
  164. <div class="col-lg-9 col-lg-offset-3">
  165. <button type="submit" class="btn btn-primary" name="signup" value="Sign up">Sign up</button>
  166. <button type="submit" class="btn btn-primary" name="signup2" value="Sign up 2">Sign up 2</button>
  167. <button type="button" class="btn btn-info" id="validateBtn">Manual validate</button>
  168. <button type="button" class="btn btn-info" id="resetBtn">Reset form</button>
  169. </div>
  170. </div>
  171. </form>
  172. </div>
  173. </section>
  174. <!-- :form -->
  175. </div>
  176. </div>
  177. <script type="text/javascript">
  178. $(document).ready(function() {
  179. // Generate a simple captcha
  180. function randomNumber(min, max) {
  181. return Math.floor(Math.random() * (max - min + 1) + min);
  182. };
  183. $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
  184. $('#defaultForm').bootstrapValidator({
  185. message: 'This value is not valid',
  186. feedbackIcons: {
  187. valid: 'glyphicon glyphicon-ok',
  188. invalid: 'glyphicon glyphicon-remove',
  189. validating: 'glyphicon glyphicon-refresh'
  190. },
  191. fields: {
  192. firstName: {
  193. validators: {
  194. notEmpty: {}
  195. }
  196. },
  197. lastName: {
  198. validators: {
  199. notEmpty: {}
  200. }
  201. },
  202. username: {
  203. message: 'The username is not valid',
  204. validators: {
  205. notEmpty: {},
  206. stringLength: {
  207. min: 6,
  208. max: 20
  209. },
  210. regexp: {
  211. regexp: /^[a-zA-Z0-9_\.]+$/,
  212. message: 'The username can only consist of alphabetical, number, dot and underscore'
  213. },
  214. remote: {
  215. url: 'remote.php',
  216. message: 'The username is not available'
  217. },
  218. different: {
  219. field: 'password',
  220. message: 'The username and password cannot be the same as each other'
  221. }
  222. }
  223. },
  224. email: {
  225. validators: {
  226. emailAddress: {}
  227. }
  228. },
  229. password: {
  230. validators: {
  231. notEmpty: {},
  232. identical: {
  233. field: 'confirmPassword',
  234. message: 'The password and its confirm are not the same'
  235. },
  236. different: {
  237. field: 'username',
  238. message: 'The password cannot be the same as username'
  239. }
  240. }
  241. },
  242. confirmPassword: {
  243. validators: {
  244. notEmpty: {},
  245. identical: {
  246. field: 'password',
  247. message: 'The password and its confirm are not the same'
  248. },
  249. different: {
  250. field: 'username',
  251. message: 'The password cannot be the same as username'
  252. }
  253. }
  254. },
  255. birthday: {
  256. validators: {
  257. date: {
  258. format: 'YYYY/MM/DD',
  259. message: 'The birthday is not valid'
  260. }
  261. }
  262. },
  263. gender: {
  264. validators: {
  265. notEmpty: {}
  266. }
  267. },
  268. 'languages[]': {
  269. validators: {
  270. notEmpty: {}
  271. }
  272. },
  273. 'programs[]': {
  274. validators: {
  275. choice: {
  276. min: 2,
  277. max: 4
  278. }
  279. }
  280. },
  281. captcha: {
  282. validators: {
  283. callback: {
  284. message: 'Wrong answer',
  285. callback: function(value, validator) {
  286. var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]);
  287. return value == sum;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. });
  294. // Validate the form manually
  295. $('#validateBtn').click(function() {
  296. $('#defaultForm').bootstrapValidator('validate');
  297. });
  298. $('#resetBtn').click(function() {
  299. $('#defaultForm').data('bootstrapValidator').resetForm(true);
  300. });
  301. });
  302. </script>
  303. </body>
  304. </html>