Not sure if there is a solution to this but I have a comments form that sits on the bottom of my page, if the page is quite long then obviously you need to scroll down to get to the comments form. The problem I have is when someone types a comment and clicks submit but they have not entered all the mandatory fields or have not entered a valid email address for example the page jumps back to the top so they would have to scroll back down again to see the error message next to the form. I have tried this with ajax enabled and disabled but it still does the same thing, is there anyway around this so when they click submit it refreshs the page at the same position they were so they can easily see the error message pop-up and make changes to their form?
Inside script tags at the top of your page will override the default scrollTo after form submit and your form will go nowhere on submit. Obviously this will cause any other scrollto functions that you might be using not to work, but who uses them?!
Excellent, that now works for when there is a validation error, the next question is can the same thing be done for when someone does submit a valid comment, can the text that is display (i.e. Thank you for your comment) be shown without refreshing the page and jumping back to the top (once again meaning they have to scroll down to the comment section to see the thank you text).
If the page properly refreshes then that won't work. Perhaps you could use a bit of javascript within the thankyou text that forces the page to scroll to it once reloaded
Thanks text
<div id="thanksVeryMuch">Thanks for filling in our form, etc etc</div> <script type="text/javascript">location.hash="thanksVeryMuch";</script>
Thanks for the response the only trouble is I do not have a div with the thank you text in, I am just using doc2form and filling in the following macro parameter: TextOnSubmit=
My other option was going to be to have it redirect to a thank you page but then I would need to have a link to take them back to the page they came from.
Call it progressive enhancement if it makes you feel better! This could be thought of as an enhancement that isn't necessary for the running of the site, everything will still be available to the minority of users that have js disabled, the majority will have the nice touch of less scrolling.
Doc2form jumping to top of page on submit
Hi,
Not sure if there is a solution to this but I have a comments form that sits on the bottom of my page, if the page is quite long then obviously you need to scroll down to get to the comments form. The problem I have is when someone types a comment and clicks submit but they have not entered all the mandatory fields or have not entered a valid email address for example the page jumps back to the top so they would have to scroll back down again to see the error message next to the form. I have tried this with ajax enabled and disabled but it still does the same thing, is there anyway around this so when they click submit it refreshs the page at the same position they were so they can easily see the error message pop-up and make changes to their form?
Its a bit cheeky, but sticking
Inside script tags at the top of your page will override the default scrollTo after form submit and your form will go nowhere on submit. Obviously this will cause any other scrollto functions that you might be using not to work, but who uses them?!
Google reveals this -> http://stackoverflow.com/questions/699171/asp-net-validation-summary-causes-page-to-jump-to-top
Excellent, that now works for when there is a validation error, the next question is can the same thing be done for when someone does submit a valid comment, can the text that is display (i.e. Thank you for your comment) be shown without refreshing the page and jumping back to the top (once again meaning they have to scroll down to the comment section to see the thank you text).
If the page properly refreshes then that won't work. Perhaps you could use a bit of javascript within the thankyou text that forces the page to scroll to it once reloaded
Thanks text
Thanks for the response the only trouble is I do not have a div with the thank you text in, I am just using doc2form and filling in the following macro parameter: TextOnSubmit=
My other option was going to be to have it redirect to a thank you page but then I would need to have a link to take them back to the page they came from.
Try putting the code in the macro parameter (using single quotes). It's worth a shot ;-)
Thanks, that seems to work, I suppose the only issue is from an accessibility point of view if javascript is disabled.
Call it progressive enhancement if it makes you feel better! This could be thought of as an enhancement that isn't necessary for the running of the site, everything will still be available to the minority of users that have js disabled, the majority will have the nice touch of less scrolling.
Dan
I can live with that, thank you for your help, another problem resolved!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.