diff options
| author | XhmikosR <[email protected]> | 2021-01-19 18:16:38 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-19 18:16:38 +0200 |
| commit | 6ffb0b48e455430f8a5359ed689ad64c1143fac2 (patch) | |
| tree | 6262338881c32c3c19e4977152ecd0fca61a341c /site/content/docs/4.6/examples/checkout/form-validation.js | |
| parent | 9d87bd7a30c1874a9c3d60041a4042228753dd0e (diff) | |
| download | bootstrap-4.6.0.tar.xz bootstrap-4.6.0.zip | |
Release v4.6.0. (#32726)v4.6.0
* Bump version to v4.6.0.
* Dist
Diffstat (limited to 'site/content/docs/4.6/examples/checkout/form-validation.js')
| -rw-r--r-- | site/content/docs/4.6/examples/checkout/form-validation.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/site/content/docs/4.6/examples/checkout/form-validation.js b/site/content/docs/4.6/examples/checkout/form-validation.js new file mode 100644 index 000000000..59291c8b3 --- /dev/null +++ b/site/content/docs/4.6/examples/checkout/form-validation.js @@ -0,0 +1,21 @@ +// 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) +})() |
