index.html 5.3 KB

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