Note that there are some explanatory texts on larger screens.

plurals
  1. POPrevent form redirect OR refresh on submit?
    text
    copied!<p>I've searched through a bunch of pages, but can't find my problem, so I had to make a post.</p> <p>I have a form that has a submit button, and when submitted I want it to NOT refresh OR redirect. I just want jQuery to perform a function.</p> <p>Here's the form:</p> <pre><code>&lt;form id="contactForm"&gt; &lt;fieldset&gt; &lt;label for="Name"&gt;Name&lt;/label&gt; &lt;input id="contactName" type="text" /&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;label for="Email"&gt;Email&lt;/label&gt; &lt;input id="contactEmail" type="text" /&gt; &lt;/fieldset&gt; &lt;fieldset class="noHeight"&gt; &lt;textarea id="contactMessage" cols="20"&gt;&lt;/textarea&gt; &lt;input id="contactSend" class="submit" type="submit" onclick="sendContactForm()" /&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;small id="messageSent"&gt;Your message has been sent.&lt;/small&gt; </code></pre> <p>And here is the jQuery:</p> <pre><code>function sendContactForm(){ $("#messageSent").slideDown("slow"); setTimeout('$("#messageSent").slideUp();$("#contactForm").slideUp("slow")', 2000); } </code></pre> <p>I've tried with and without an action element on the form, but don't know what I'm doing wrong. What has annoyed me more is that I have an example that does it perfectly: <a href="http://designshack.co.uk/articles/javascript/creating-a-slide-in-jquery-contact-form/comment-page-2#comment-1213" rel="noreferrer" title="Example page">Example Page</a></p> <p>If you want to see my problem live, goto <a href="http://stormink.net" rel="noreferrer">stormink.net</a> (my site) and check out the sidebar where it says "Send me and email" and "RSS Subscription". Both are forms that I'm trying to get this to work on.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload