specialName.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. <script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
  8. <script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
  9. <script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
  10. </head>
  11. <body>
  12. <div class="container">
  13. <div class="row">
  14. <div class="col-lg-8 col-lg-offset-2">
  15. <div class="page-header">
  16. <h2>Using special names such as user[firtName], user.username</h2>
  17. </div>
  18. <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
  19. <div class="form-group">
  20. <label class="col-lg-3 control-label">Full name</label>
  21. <div class="col-lg-4">
  22. <input type="text" class="form-control" name="user[firstName]" placeholder="First name" />
  23. </div>
  24. <div class="col-lg-4">
  25. <input type="text" class="form-control" name="user[lastName]" placeholder="Last name" />
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label class="col-lg-3 control-label">Username</label>
  30. <div class="col-lg-5">
  31. <input type="text" class="form-control" name="user.username" />
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <label class="col-lg-3 control-label">Email address</label>
  36. <div class="col-lg-5">
  37. <input type="text" class="form-control" name="user.email" />
  38. </div>
  39. </div>
  40. <div class="form-group">
  41. <label class="col-lg-3 control-label">Password</label>
  42. <div class="col-lg-5">
  43. <input type="password" class="form-control" name="user[password]" id="password" />
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <label class="col-lg-3 control-label">Gender</label>
  48. <div class="col-lg-5">
  49. <div class="radio">
  50. <label>
  51. <input type="radio" name="gender" value="male" /> Male
  52. </label>
  53. </div>
  54. <div class="radio">
  55. <label>
  56. <input type="radio" name="gender" value="female" /> Female
  57. </label>
  58. </div>
  59. <div class="radio">
  60. <label>
  61. <input type="radio" name="gender" value="other" /> Other
  62. </label>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="form-group">
  67. <label class="col-lg-3 control-label">Birthday</label>
  68. <div class="col-lg-5">
  69. <input type="text" class="form-control" name="birthday" /> (YYYY/MM/DD)
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <div class="col-lg-9 col-lg-offset-3">
  74. <button type="submit" class="btn btn-primary" name="signup" value="Sign up">Sign up</button>
  75. </div>
  76. </div>
  77. </form>
  78. </div>
  79. </div>
  80. </div>
  81. <script type="text/javascript">
  82. $(document).ready(function() {
  83. $('#defaultForm').bootstrapValidator({
  84. // live: 'disabled',
  85. message: 'This value is not valid',
  86. feedbackIcons: {
  87. valid: 'glyphicon glyphicon-ok',
  88. invalid: 'glyphicon glyphicon-remove',
  89. validating: 'glyphicon glyphicon-refresh'
  90. },
  91. fields: {
  92. 'user[firstName]': {
  93. validators: {
  94. notEmpty: {
  95. message: 'The first name is required and cannot be empty'
  96. }
  97. }
  98. },
  99. 'user[lastName]': {
  100. validators: {
  101. notEmpty: {
  102. message: 'The last name is required and cannot be empty'
  103. }
  104. }
  105. },
  106. 'user.username': {
  107. message: 'The username is not valid',
  108. validators: {
  109. notEmpty: {
  110. message: 'The username is required and cannot be empty'
  111. },
  112. stringLength: {
  113. min: 6,
  114. max: 30,
  115. message: 'The username must be more than 6 and less than 30 characters long'
  116. },
  117. regexp: {
  118. regexp: /^[a-zA-Z0-9_\.]+$/,
  119. message: 'The username can only consist of alphabetical, number, dot and underscore'
  120. },
  121. remote: {
  122. url: 'remote.php',
  123. message: 'The username is not available'
  124. },
  125. different: {
  126. field: 'user[password]',
  127. message: 'The username and password cannot be the same as each other'
  128. }
  129. }
  130. },
  131. 'user.email': {
  132. validators: {
  133. emailAddress: {
  134. message: 'The input is not a valid email address'
  135. }
  136. }
  137. },
  138. 'user[password]': {
  139. // It still work event if you use selector option
  140. //selector: '#password',
  141. validators: {
  142. notEmpty: {
  143. message: 'The password is required and cannot be empty'
  144. },
  145. different: {
  146. field: 'user.username',
  147. message: 'The password cannot be the same as username'
  148. }
  149. }
  150. },
  151. birthday: {
  152. validators: {
  153. date: {
  154. format: 'YYYY/MM/DD',
  155. message: 'The birthday is not valid'
  156. }
  157. }
  158. },
  159. gender: {
  160. validators: {
  161. notEmpty: {
  162. message: 'The gender is required'
  163. }
  164. }
  165. }
  166. }
  167. });
  168. });
  169. </script>
  170. </body>
  171. </html>