formWithoutLabels.html 4.1 KB

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