aboutsummaryrefslogtreecommitdiff
path: root/site/assets/js/validate-forms.js
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2020-05-14 11:36:39 +0300
committerXhmikosR <[email protected]>2021-01-18 22:37:22 +0200
commit6521761aff02d1ceb1803f1d807c19366c7cc0dd (patch)
treebe37678d5589b1637059c4614afc46831a9efe41 /site/assets/js/validate-forms.js
parent4167c107f81aeb2b05e3fe3e2e511b50ea9be640 (diff)
downloadbootstrap-main-xmr-docs-hugo-rm-ver.tar.xz
bootstrap-main-xmr-docs-hugo-rm-ver.zip
Docs: remove version folder from static filesmain-xmr-docs-hugo-rm-ver
Use a mount instead.
Diffstat (limited to 'site/assets/js/validate-forms.js')
-rw-r--r--site/assets/js/validate-forms.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/site/assets/js/validate-forms.js b/site/assets/js/validate-forms.js
new file mode 100644
index 000000000..f8fd583de
--- /dev/null
+++ b/site/assets/js/validate-forms.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)
+ })
+})()