I have set up a form in a pop-up using Bootstrap modal. The form is quite long, so after submission, the message appears at the top of the form. However, I want it to scroll to the top when the user submits the form so they can easily see the message.
Is this achievable? Since it's a pop-up modal, please take a look at my code below and let me know if there are any errors.
$(document).ready(function() {
$('.reg-form').on('submit', function(e) {
$('#register').on('shown', function() {
$(this).scrollTop(0);
});
$('.load').fadeIn(500);
var formData = new FormData(this);
});
});
Below is the HTML for my pop-up modal.
<div id="register" class="modal" role="dialog">
<button type="button" class="close" data-dismiss="modal">
<img class="svg" src="<?php echo base_url(); ?>assets/images/modal-close.svg">
</button>
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Register With Us</h4>
</div>
<div class="modal-body">
//form goes here
</div>
</div>
</div>
</div>