index.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. <!-- form: -->
  15. <section>
  16. <div class="col-lg-8 col-lg-offset-2">
  17. <div class="page-header">
  18. <h2>Sign up</h2>
  19. </div>
  20. <form id="defaultForm" method="post" class="form-horizontal">
  21. <div class="form-group">
  22. <label class="col-m col-lg-3 control-label">Username</label>
  23. <div class="col-lg-5">
  24. <input type="text" class="form-control" name="username" />
  25. </div>
  26. </div>
  27. <div class="form-group">
  28. <label class="col-lg-3 control-label">Email address</label>
  29. <div class="col-lg-5">
  30. <input type="text" class="form-control" name="email" />
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label class="col-lg-3 control-label">Password</label>
  35. <div class="col-lg-5">
  36. <input type="password" class="form-control" name="password" />
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label class="col-lg-3 control-label">Retype password</label>
  41. <div class="col-lg-5">
  42. <input type="password" class="form-control" name="confirmPassword" />
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <div class="col-lg-9 col-lg-offset-3">
  47. <button type="submit" class="btn btn-primary">Sign up</button>
  48. </div>
  49. </div>
  50. </form>
  51. </div>
  52. </section>
  53. <!-- :form -->
  54. </div>
  55. </div>
  56. <script type="text/javascript">
  57. $(document).ready(function() {
  58. $('#defaultForm').bootstrapValidator({
  59. message: 'This value is not valid',
  60. fields: {
  61. username: {
  62. message: 'The username is not valid',
  63. validators: {
  64. notEmpty: {
  65. message: 'The username is required and can\'t be empty'
  66. },
  67. stringLength: {
  68. min: 6,
  69. max: 30,
  70. message: 'The username must be more than 6 and less than 30 characters long'
  71. },
  72. regexp: {
  73. regexp: /^[a-zA-Z0-9_\.]+$/,
  74. message: 'The username can only consist of alphabetical, number, dot and underscore'
  75. },
  76. different: {
  77. field: 'password',
  78. message: 'The username and password can\'t be the same as each other'
  79. }
  80. }
  81. },
  82. email: {
  83. validators: {
  84. notEmpty: {
  85. message: 'The email address is required and can\'t be empty'
  86. },
  87. emailAddress: {
  88. message: 'The input is not a valid email address'
  89. }
  90. }
  91. },
  92. password: {
  93. validators: {
  94. notEmpty: {
  95. message: 'The password is required and can\'t be empty'
  96. },
  97. identical: {
  98. field: 'confirmPassword',
  99. message: 'The password and its confirm are not the same'
  100. },
  101. different: {
  102. field: 'username',
  103. message: 'The password can\'t be the same as username'
  104. }
  105. }
  106. },
  107. confirmPassword: {
  108. validators: {
  109. notEmpty: {
  110. message: 'The confirm password is required and can\'t be empty'
  111. },
  112. identical: {
  113. field: 'password',
  114. message: 'The password and its confirm are not the same'
  115. },
  116. different: {
  117. field: 'username',
  118. message: 'The password can\'t be the same as username'
  119. }
  120. }
  121. }
  122. }
  123. });
  124. });
  125. </script>
  126. </body>
  127. </html>