Ben Hayes Ben Hayes - 1 year ago 140
Javascript Question

Scroll to first Form Error Using LiveValidation

I am looking for a way to scroll to the first error using only the LiveValidation 1.3 JavaScript library. I see examples online of how to do it in general, but nothing for LiveValidation. This is for an Eloqua form that uses the LiveValidation script.

Answer Source

I have solved my own issue. The code did not work when targeting ".LV_invalid:first" by itself, but when I target the ".parent('p')" it now works fine.

  var form = $('form');
  $(form).on('submit', function() {
    $('html, body').animate({
     scrollTop: $(".LV_invalid:first").parent('p').offset().top
    }, 500);
    return false;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download