Bootstrap

Validatie van invoervelden

Validatie van invoervelden
<form class="needs-validation" novalidate>
<div class="form-group position-relative">
<input type="text" class="form-control" placeholder="Woonplaats" required>
<div class="invalid-feedback feedback-icon"><i class="fas fa-exclamation-circle"></i> Laat het ons weten waar u woont </div>
</div> 
<button class="btn btn-primary btn-sm" type="submit">Verzenden</button>
</form>
<script>
(function() {
'use strict';
window.addEventListener('load', function() {
var forms = document.getElementsByClassName('needs-validation');
var validation = 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);
})();
</script>
Bootstrap Lessons for Beginners
Form Validation