mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-04 16:24:22 +01:00
fe257823ec
* Pass docs js through Babel * Use ES6 in docs js * Only run babel on src files * Allow babel in Hugo * Update scripts.html * Inherit from the root .eslintrc.json * Use `Array.from` * Drop Babel from docs * Prefer template * replace IIFE with arrow functions Co-authored-by: XhmikosR <xhmikosr@gmail.com> Co-authored-by: GeoSot <geo.sotis@gmail.com>
20 lines
559 B
JavaScript
20 lines
559 B
JavaScript
// Example starter JavaScript for disabling form submissions if there are invalid fields
|
|
(() => {
|
|
'use strict'
|
|
|
|
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
|
const forms = document.querySelectorAll('.needs-validation')
|
|
|
|
// Loop over them and prevent submission
|
|
Array.from(forms).forEach(form => {
|
|
form.addEventListener('submit', event => {
|
|
if (!form.checkValidity()) {
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
}
|
|
|
|
form.classList.add('was-validated')
|
|
}, false)
|
|
})
|
|
})()
|