Perch Forms: form action="#custom" without adding it to my URL

  • I have a one page website with a perch contact form at the bottom.

    On submission of the form I want the page to scroll back down to the form so that it can display the success message where the form used to be.


    I've achieved this by adding:

    Code
    1. <perch:form action="#contact-us"

    And it works.. The problem is.. it's adding #contact-us to my URL and I don't want this to happen. Any ideas how I can do this?


    Here's my full form below. I also have a basic preventDefault script running:

    Code
    1. $(function(){
    2. $('a[href="#"]').click(function(event){
    3. event.preventDefault();
    4. });
    5. });


  • drewm

    Approved the thread.
  • I get what you're saying there.

    But actually that's part of my problem..

    If the user does refresh the page.

    Then in chrome (At least) they get the following alert :

    'Confirm form Resubmission - The page that you're looking for used information that you entered. Returning to that page might cause any action you took to be repeated. Do you want to continue?'

    If they Click yes it submits a duplicate entry. If they click cancel then it just returns them to the site.

    Maybe that is the correct behavior and I'm looking at this as a problem that doesn't exist?

  • That warning happens with any form submission, whether the URL has a fragment identifier or not.


    I think your best approach might be to remove the fragment identifier with JavaScript if it bothers you.