Form submit scrolls to top of the page when error

42 views
Skip to first unread message

Joe

unread,
Feb 5, 2016, 2:12:48 AM2/5/16
to web2py-users
My form is in the bottom of the page. When I submit the form, if there is an error, the error msg (Enter Value) works as expected but after submission the user is sent back to the top of the page so he can't see the error msgs.
How can I keep the page where it is when the form is submitted if there is an error? I am using a template so I am not extending the Web2py layout.html.
I would appreciate some advise.
Thanks very much.
Cheers,
Joe

Anthony

unread,
Feb 5, 2016, 12:11:29 PM2/5/16
to web2py-users
That's just how the browser works. When there is an error, you might consider adding a message at the top of the page with a link down to the form. Alternatively, you could use Javascript to scroll down to the form -- see http://jsfiddle.net/thinkingstiff/dg8yr/.

Anthony

Joe

unread,
Feb 13, 2016, 9:37:10 PM2/13/16
to web2py-users
Thanks Anthony, Yes, I was originally considering adding a message at the top of the page, I just thought perhaps there might be an other way. In any case, that's what I did, added a message at the top and that's fine. Thanks again for your kind reply. Cheers, Joe
Reply all
Reply to author
Forward
0 new messages