diff options
Diffstat (limited to 'src/main/resources/static/js/form-validation.js')
| -rwxr-xr-x | src/main/resources/static/js/form-validation.js | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/src/main/resources/static/js/form-validation.js b/src/main/resources/static/js/form-validation.js new file mode 100755 index 0000000..f8fd583 --- /dev/null +++ b/src/main/resources/static/js/form-validation.js @@ -0,0 +1,20 @@ +// Example starter JavaScript for disabling form submissions if there are invalid fields +(function () { +  'use strict' + +  // Fetch all the forms we want to apply custom Bootstrap validation styles to +  var forms = document.querySelectorAll('.needs-validation') + +  // Loop over them and prevent submission +  Array.prototype.slice.call(forms) +    .forEach(function (form) { +      form.addEventListener('submit', function (event) { +        if (!form.checkValidity()) { +          event.preventDefault() +          event.stopPropagation() +        } + +        form.classList.add('was-validated') +      }, false) +    }) +})() |