When form is validated, how to SCROLL to the first error instead of jumping?

后端 未结 6 735
一向
一向 2021-01-30 01:34

I\'ve seen many questions with variations on this theme, but I\'m looking for the straightforward solution:

HTML form, jQuery validation, multiple fields are required. W

6条回答
  •  庸人自扰
    2021-01-30 01:59

    Maybe you could check what input failed and take it's position (top) and use jQuery's scrollTop

    $(window).scrollTop(errorPosition)
    

    It seems that getting each error field isn't very easy to get (at least for me).

    Search for errorPlacement in the Validation plugin documentation. There is an example how to get each error field.

提交回复
热议问题