We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23838
    • 11 Posts
    Hi Forum

    I have a formit form in the footer of a site, and currently when there is a validation error the page is just reloaded and the user is sent back to the top of the page. The error messages are displaying as they should but the problem is I want to send the user to the top of the form in the footer on an error instead. Is there anyway to specify which section (i.e. a div) the user is directed to on the error validation? How would I do this?

    Thanks
    Steve
      • 40045
      • 534 Posts
      I don’t think there’s a built in way to do this, I would try it with javascript (in my case jQuery). Looking for .error (or what ever class your validation errors have) and if there are some, scroll to the form with some plugin like scrollTo or so...
        • 12028
        • 152 Posts
        You can do it with anchors:

        <form action="[[~[[*id]]]]#message" method="post" class="form">
        <div id="message">
        ... Your message content here ...
        </div>
        ... Your input fields here ...
        </form>


        Hope it helps! [ed. note: Henrik Nielsen last edited this post 12 years, 7 months ago.]
          - A small step for mankind, so why not take two...

          Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
          • 23838
          • 11 Posts
          Thanks Henrik - that worked perfectly.
            • 40045
            • 534 Posts
            Nice! Learned something again =)