index.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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/identical.js"></script>
  14. <script type="text/javascript" src="../src/js/validator/notEmpty.js"></script>
  15. <script type="text/javascript" src="../src/js/validator/regexp.js"></script>
  16. <script type="text/javascript" src="../src/js/validator/stringLength.js"></script>
  17. </head>
  18. <body>
  19. <div class="container">
  20. <div class="row">
  21. <!-- form: -->
  22. <section>
  23. <div class="page-header">
  24. <h2>Default Bootstrap form</h2>
  25. </div>
  26. <div class="col-lg-4 col-lg-offset-4">
  27. <form id="defaultForm" method="post">
  28. <div class="form-group">
  29. <input type="text" class="form-control" name="username" placeholder="Username" />
  30. </div>
  31. <div class="form-group">
  32. <input type="text" class="form-control" name="email" placeholder="Email" />
  33. </div>
  34. <div class="form-group">
  35. <input type="password" class="form-control" name="password" placeholder="Password" />
  36. </div>
  37. <div class="form-group">
  38. <input type="password" class="form-control" name="confirmPassword" placeholder="Retype password" />
  39. </div>
  40. <button type="submit" class="btn btn-primary">Sign up</button>
  41. </form>
  42. </div>
  43. </section>
  44. <!-- :form -->
  45. </div>
  46. </div>
  47. <script type="text/javascript">
  48. $(document).ready(function() {
  49. $('#defaultForm').bootstrapValidate({
  50. fields: {
  51. username: {
  52. message: 'The username is not valid',
  53. validator: {
  54. notEmpty: {
  55. message: 'The username is required and can\'t be empty'
  56. },
  57. stringLength: {
  58. min: 6,
  59. max: 30,
  60. message: 'The username must be more than 6 and less than 30 characters long'
  61. },
  62. regexp: {
  63. regexp: /^[a-zA-Z0-9_\.]+$/,
  64. message: 'The username can only consist of alphabetical, number, dot and underscore'
  65. }
  66. }
  67. },
  68. email: {
  69. validator: {
  70. notEmpty: {
  71. message: 'The email address is required and can\'t be empty'
  72. }
  73. }
  74. },
  75. password: {
  76. validator: {
  77. notEmpty: {
  78. message: 'The password is required and can\'t be empty'
  79. },
  80. identical: {
  81. field: 'confirmPassword',
  82. message: 'The password and its confirm are not the same'
  83. }
  84. }
  85. },
  86. confirmPassword: {
  87. validator: {
  88. notEmpty: {
  89. message: 'The confirm password is required and can\'t be empty'
  90. },
  91. identical: {
  92. field: 'password',
  93. message: 'The password and its confirm are not the same'
  94. }
  95. }
  96. }
  97. },
  98. message: 'This value is not valid',
  99. iconClass: {
  100. valid: 'icon-ok',
  101. invalid: 'icon-remove'
  102. }
  103. });
  104. });
  105. </script>
  106. </body>
  107. </html>