Despite multiple searches on Google, I haven't been able to find a solution to my problem. I'm using a validation form from bootstrap 4 and all I want to do is link a button to a different page. Using the anchor tag like this:
<a href="www.mysite.com" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Submit</a>
works, but it bypasses the validation process.
Currently, I have this button within a form:
<button class="btn btn-primary" type="submit" >Submit form</button>
</form>
And here is the JavaScript that goes with it:
<script>
// 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
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>
I would appreciate any help in figuring out what needs to be added to the javascript file in order to make the button functional. Thank you!