You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

form-validation.js 705B

2 yıl önce
12345678910111213141516171819
  1. // Example starter JavaScript for disabling form submissions if there are invalid fields
  2. (function() {
  3. 'use strict';
  4. window.addEventListener('load', function() {
  5. // Fetch all the forms we want to apply custom Bootstrap validation styles to
  6. var forms = document.getElementsByClassName('needs-validation');
  7. // Loop over them and prevent submission
  8. var validation = Array.prototype.filter.call(forms, function(form) {
  9. form.addEventListener('submit', function(event) {
  10. if (form.checkValidity() === false) {
  11. event.preventDefault();
  12. event.stopPropagation();
  13. }
  14. form.classList.add('was-validated');
  15. }, false);
  16. });
  17. }, false);
  18. })();