formWithoutLabels.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. feedbackIcons: {
  47. valid: 'glyphicon glyphicon-ok',
  48. invalid: 'glyphicon glyphicon-remove',
  49. validating: 'glyphicon glyphicon-refresh'
  50. },
  51. fields: {
  52. username: {
  53. message: 'The username is not valid',
  54. validators: {
  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. validators: {
  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. validators: {
  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. validators: {
  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. });
  103. });
  104. </script>
  105. </body>
  106. </html>