When I finish validating the form, I want to show a success message but it automatically refreshes and does not allow time to see anything. I'm using bootstrap 4.1.3
This is my portion code:
<div class="container">
<div class="py-5 text-center">
<h2>Inscription 2019</h2>
<div id="alertOk" class="alert alert-success d-none" role="alert">
Success!
</div>
</div>
<div class="col-md-12 order-md-1">
<h5 class="mb-3">* Especialidad</h5>
<form id="inscriptoForm" class="needs-validation" novalidate>
<div class="row">
<div class="col-md-4 mb-3">
<label for="firstName">* Name</label>
<input type="text" class="form-control" id="name" name="name" required>
<div class="invalid-feedback">
Name is required.
</div>
</div>
</div>
<script type='text/javascript'>
(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();
} else {
$('#alertOk').removeClass('d-none'); //remove class to show message.
}
}, false);
});
}, false);
})();
The validation works but when you click on the submit, it shows the message very quickly and can not be read. Return the blank form.