labelWithoutClass.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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" style="margin-top: 50px;">
  13. <div class="row">
  14. <div class="col-lg-4 col-lg-offset-4">
  15. <div class="panel panel-default">
  16. <div class="panel-heading">
  17. <h3 class="panel-title">Sign up</h3>
  18. </div>
  19. <div class="panel-body">
  20. <form id="defaultForm" method="post">
  21. <div class="form-group">
  22. <label>Username</label>
  23. <input type="text" class="form-control" name="username" placeholder="Username" />
  24. </div>
  25. <div class="form-group">
  26. <label>Email</label>
  27. <input type="text" class="form-control" name="email" placeholder="Email" />
  28. </div>
  29. <div class="form-group">
  30. <label>Password</label>
  31. <input type="password" class="form-control" name="password" placeholder="Password" />
  32. </div>
  33. <div class="form-group">
  34. <label>Retype password</label>
  35. <input type="password" class="form-control" name="confirmPassword" placeholder="Retype password" />
  36. </div>
  37. <div class="form-group">
  38. <button type="submit" class="btn btn-primary">Sign up</button>
  39. </div>
  40. </form>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <script type="text/javascript">
  47. $(document).ready(function() {
  48. $('#defaultForm').bootstrapValidator({
  49. message: 'This value is not valid',
  50. fields: {
  51. username: {
  52. message: 'The username is not valid',
  53. validators: {
  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. validators: {
  70. notEmpty: {
  71. message: 'The email address is required and can\'t be empty'
  72. },
  73. emailAddress: {
  74. message: 'The input is not a valid email address'
  75. }
  76. }
  77. },
  78. password: {
  79. validators: {
  80. notEmpty: {
  81. message: 'The password is required and can\'t be empty'
  82. },
  83. identical: {
  84. field: 'confirmPassword',
  85. message: 'The password and its confirm are not the same'
  86. }
  87. }
  88. },
  89. confirmPassword: {
  90. validators: {
  91. notEmpty: {
  92. message: 'The confirm password is required and can\'t be empty'
  93. },
  94. identical: {
  95. field: 'password',
  96. message: 'The password and its confirm are not the same'
  97. }
  98. }
  99. }
  100. }
  101. });
  102. });
  103. </script>
  104. </body>
  105. </html>