source:
public/assets/js/examples/form-validator.js@
c6fe0df
Last change on this file since c6fe0df was 194a359, checked in by , 3 years ago | |
---|---|
|
|
File size: 701 bytes |
Rev | Line | |
---|---|---|
[194a359] | 1 | (function () { |
2 | 'use strict'; | |
3 | window.addEventListener('load', function () { | |
4 | // Fetch all the forms we want to apply custom Bootstrap validation styles to | |
5 | var forms = document.getElementsByClassName('needs-validation'); | |
6 | // Loop over them and prevent submission | |
7 | var validation = Array.prototype.filter.call(forms, function (form) { | |
8 | form.addEventListener('submit', function (event) { | |
9 | if (form.checkValidity() === false) { | |
10 | event.preventDefault(); | |
11 | event.stopPropagation(); | |
12 | } | |
13 | form.classList.add('was-validated'); | |
14 | }, false); | |
15 | }); | |
16 | }, false); | |
17 | })(); |
Note:
See TracBrowser
for help on using the repository browser.