form-validation.js 748 B

123456789101112131415161718192021222324
  1. (function() {
  2. 'use strict';
  3. // SELECT2
  4. $('.select2').select2({
  5. minimumResultsForSearch: Infinity
  6. });
  7. window.addEventListener('load', function() {
  8. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  9. var forms = document.getElementsByClassName('needs-validation');
  10. // Loop over them and prevent submission
  11. var validation = Array.prototype.filter.call(forms, function(form) {
  12. form.addEventListener('submit', function(event) {
  13. if (form.checkValidity() === false) {
  14. event.preventDefault();
  15. event.stopPropagation();
  16. }
  17. form.classList.add('was-validated');
  18. }, false);
  19. });
  20. }, false);
  21. })();