reset.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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">
  13. <div class="row">
  14. <div class="col-lg-8 col-lg-offset-2">
  15. <div class="page-header">
  16. <h2>Reset form example</h2>
  17. </div>
  18. <form id="defaultForm" method="post" class="form-horizontal" action="target.php">
  19. <div class="form-group">
  20. <label class="col-lg-3 control-label">Full name</label>
  21. <div class="col-lg-4">
  22. <input type="text" class="form-control" name="firstName" placeholder="First name" />
  23. </div>
  24. <div class="col-lg-4">
  25. <input type="text" class="form-control" name="lastName" placeholder="Last name" />
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label class="col-lg-3 control-label">Email address</label>
  30. <div class="col-lg-5">
  31. <input type="text" class="form-control" name="email" />
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <label class="col-lg-3 control-label">Gender</label>
  36. <div class="col-lg-5">
  37. <div class="radio">
  38. <label>
  39. <input type="radio" name="gender" value="male" /> Male
  40. </label>
  41. </div>
  42. <div class="radio">
  43. <label>
  44. <input type="radio" name="gender" value="female" /> Female
  45. </label>
  46. </div>
  47. <div class="radio">
  48. <label>
  49. <input type="radio" name="gender" value="other" /> Other
  50. </label>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <div class="col-lg-9 col-lg-offset-3">
  56. <button type="submit" class="btn btn-primary">Join Us</button>
  57. </div>
  58. </div>
  59. </form>
  60. </div>
  61. </div>
  62. </div>
  63. <!-- The modal -->
  64. <div class="modal fade" id="helloModal">
  65. <div class="modal-dialog">
  66. <div class="modal-content">
  67. <div class="modal-header">
  68. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  69. <h4 class="modal-title">Hello</h4>
  70. </div>
  71. <div class="modal-body">
  72. <div class="text-center welcome"></div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <script type="text/javascript">
  78. $(document).ready(function() {
  79. $('#defaultForm').bootstrapValidator({
  80. feedbackIcons: {
  81. valid: 'glyphicon glyphicon-ok',
  82. invalid: 'glyphicon glyphicon-remove',
  83. validating: 'glyphicon glyphicon-refresh'
  84. },
  85. submitHandler: function(validator, form, submitButton) {
  86. // Show the modal
  87. var fullName = [validator.getFieldElements('firstName').val(),
  88. validator.getFieldElements('lastName').val()].join(' ');
  89. $('#helloModal')
  90. .find('.welcome').html('Hello ' + fullName).end()
  91. .modal('show');
  92. $('#defaultForm')
  93. .bootstrapValidator('disableSubmitButtons', false) // Enable the submit buttons
  94. .bootstrapValidator('resetForm', true); // Reset the form
  95. },
  96. fields: {
  97. firstName: {
  98. validators: {
  99. notEmpty: {
  100. message: 'The first name is required and cannot be empty'
  101. }
  102. }
  103. },
  104. lastName: {
  105. validators: {
  106. notEmpty: {
  107. message: 'The last name is required and cannot be empty'
  108. }
  109. }
  110. },
  111. email: {
  112. validators: {
  113. notEmpty: {
  114. message: 'The email address is required and cannot be empty'
  115. },
  116. emailAddress: {
  117. message: 'The input is not a valid email address'
  118. }
  119. }
  120. },
  121. gender: {
  122. validators: {
  123. notEmpty: {
  124. message: 'The gender is required'
  125. }
  126. }
  127. }
  128. }
  129. });
  130. });
  131. </script>
  132. </body>
  133. </html>