ericelliott / h5Validate

An HTML5 form validation plugin for jQuery. Works on all major browsers, both new and old. Implements inline, realtime validation best practices (based on surveys and usability studies). Developed for production use in e-commerce. Currently in production with millions of users.
576 stars 125 forks source link

Long form, scroll to error? #99

Open sporkman opened 9 years ago

sporkman commented 9 years ago

I'm very much a JS noob. I have the validation working, and I love the idea of this project - basically make the browser act like it truly supports html5 validation. :)

I have a very long form, that even on an iPad has form items out of view when hitting "submit". Is there a simple way to have the browser scroll up to where the first error exists?

ericelliott commented 9 years ago

Sure. You can listen for the formValidated event and scroll to the first element with an error. There is a jQuery plugin that will let you scroll to a selected element.