container2.html 6.7 KB

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