Skip to content

Scroll to the first error

Geremia Taglialatela edited this page Feb 6, 2026 · 6 revisions

This is an example implementation, you may require more checks, in example if a navbar is present or if the layout is different:

ClientSideValidations.callbacks.form.fail = function($form, eventData) {
  const settings = $form[0].ClientSideValidations.settings;
  const $errorElement = $form.find(`.${settings.html_settings.wrapper_error_class}`);

  if ($errorElement.length) {
    $('html').animate({
      scrollTop: $errorElement.offset().top
    });
  }
};

Clone this wiki locally