- Written by
Colin
- Posted October 7, 2010 at 11:56 am
I came across an issue today with a validation summary form on a sign up form. The form was at the bottom of a page containing much text…well that’s what was in the design and it will probably turn into “Please sign up here” once the client get’s their hands on it. But that’s par for the course.
Now because the sign up form was below the lorem ipsum text in the design, I also placed the validation summary below this. But this causes a small technical issue when you hit the submit button and some of your elements do not validate, the whole page scrolls to the top. Not very easy for a user to see what went wrong without scrolling back to the form.
Why does this happen? Microsoft in their infinite wisdom have placed some really annoying javascript into their validation code. If you inspect the shite that Microsoft pumps into the page with a form and validation controls, you may find (there is a lot of code) a window.scrollTo(0,0) line buried away. This of course scrolls your window back to the top. For most cases this will be fine, as most cases the form is not preceded by craps loads of text, and your validation summary will either be at the top, or be as close as dammit to it. Not in my case, and not as it seems many others. So I had to find a solution. Read the rest of this entry »