index.html 4.5 KB

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