jquery-steps icon indicating copy to clipboard operation
jquery-steps copied to clipboard

Scrolling to required field form validation

Open kiddynomite opened this issue 4 years ago • 0 comments

Hello,

I'm having an issue with scrolling to an input.error or select.error when trying to change steps. It wants to jump to the error class / tab button on the current step instead (class="current error"). I've tried setting autoFocus to false and supressPaginationOnFocus to true with no luck. Is there a simple way to ? In the onStepChanging method I'm simply trying to scroll to the closest error:

if (form.valid())
                        return true;
                    else {
                        var errors = $('select.error, input.error')
                        if (errors.length) {
                            setTimeout(function () {
                                if (form.closest('.modal-body').length) {
                                    form.closest('.modal-body').off('scroll');
                                    form.closest('.modal-body').animate({ scrollTop: errors.eq(0).offset().top - form.closest('.bootstrap-dialog-message').offset().top - 30}, 500);
                                } else {
                                    $('body').animate({ scrollTop: errors.eq(0).offset().top }, 'fast')
                                }
                            }, 100);
                        }
                        return false;

Thanks for any insight.

kiddynomite avatar Nov 11 '20 20:11 kiddynomite