diff options
| author | Mark Otto <[email protected]> | 2019-02-11 11:15:34 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-02-11 11:15:34 -0800 |
| commit | 1ded0d6a4eefb7daca62c44e4e735aec200f0b6f (patch) | |
| tree | e0036e5068cfb8e2c17971c4e892bd6b502dda9a /site/docs/4.3/examples/checkout/form-validation.js | |
| parent | 3aa0770b711f69c4dcf5858b8913794e81b32d80 (diff) | |
| download | bootstrap-4.3.0.tar.xz bootstrap-4.3.0.zip | |
Release v4.3.0 (#28228)v4.3.0
* Prep for v4.3.0
* More updates for v4.3.0.
* rerun to build docs source map
Diffstat (limited to 'site/docs/4.3/examples/checkout/form-validation.js')
| -rw-r--r-- | site/docs/4.3/examples/checkout/form-validation.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/site/docs/4.3/examples/checkout/form-validation.js b/site/docs/4.3/examples/checkout/form-validation.js new file mode 100644 index 000000000..280849408 --- /dev/null +++ b/site/docs/4.3/examples/checkout/form-validation.js @@ -0,0 +1,20 @@ +// Example starter JavaScript for disabling form submissions if there are invalid fields +(function () { + 'use strict' + + window.addEventListener('load', function () { + // Fetch all the forms we want to apply custom Bootstrap validation styles to + var forms = document.getElementsByClassName('needs-validation') + + // Loop over them and prevent submission + Array.prototype.filter.call(forms, function (form) { + form.addEventListener('submit', function (event) { + if (form.checkValidity() === false) { + event.preventDefault() + event.stopPropagation() + } + form.classList.add('was-validated') + }, false) + }) + }, false) +}()) |
