ansman / validate.js

A declarative validation library written javascript
https://validatejs.org
MIT License
2.63k stars 336 forks source link

Scroll to first error #327

Closed adelacreative closed 4 years ago

adelacreative commented 4 years ago

How can we scroll to the first error the form finds? If the form is big and error is at top, it's not visible.

tcdurks commented 4 years ago

i'm using this inside handleFormSubmit()

    if(errors){
      $('html, body').animate({
        scrollTop: $('.your-error-class').offset().top -100
      }, 1000);
    } 
adelacreative commented 4 years ago

Thank you very much, this is exactly what I needed!