Answers.Body: <p>You can add a param to your <code>returnUrl</code> in the form composer then check the template for the param.</p>
  
  <p>For example:</p>
  
  <p>You redirect to <code>/contact?success</code></p>
  
  <pre><code>{% set successParam = craft.request.getParam('success') %}
  {% if successParam is not null %} 
    &lt;p&gt;Hooray! Success!!&lt;/p&gt;
  {% endif %}
  </code></pre>
  
  <p>Another option is to Ajax submit your form and just have a modal or something on a succes submit. An example of an Ajax submit can be found in the official freeform docs <a href="https://solspace.com/craft/freeform/docs/ajax-forms/" rel="nofollow noreferrer">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-29T18:57:46.590Z
Answers.Text: Thanks. I tried that, and setup a route to use my same contact template and it displayed the success message...the problem with that route is that contact is a single in Craft. So if i access it at contact/success it doesn't have the {{ entry }} fields. Am I doing something wrong? I want to use the same template for contact and contact/success. Perhaps i do need to go the ajax route.
Answers.UserDisplayName: Shift2Design
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-29T19:03:20.570Z
Answers.Text: Instead of returning a new segment you can return a param. I'll edit my answer
Answers.UserDisplayName: Jan_dh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-29T19:10:36.497Z
Answers.Text: Great idea. It's fixed. I don't post here often, what is the best way to post the working code?
Answers.UserDisplayName: Shift2Design
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-29T19:14:40.407Z
Answers.Text: You can edit your original question with a little note that that is the working code. Welcome to the Craft family ;)
Answers.UserDisplayName: Jan_dh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-29T19:29:33.753Z
Answers.Text: I updated original question with some working code. Thank you.
Answers.UserDisplayName: Shift2Design
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-01-29T18:54:08.997Z
Answers.LastActivityDate: 2019-11-25T14:42:15.187Z
Answers.LastEditDate: 2019-11-25T14:42:15.187Z
Answers.UserDisplayName: Jan_dh
Body: <p>I am having trouble getting a freeform success message to display. I am posting back to the same template. What is the proper way to check if the form was posted? I see in the freeform render template there is a freeform.hasErrors, is there something for success perhaps?</p>
  
  <pre><code>            {% if craft.request.getPost('firstName')|length %}
  
                  &lt;div class="callout success"&gt;Your message has been sent.&lt;/div&gt;
  
              {% else %}
  
                  {{ craft.freeform.form("contactForm", {
                          formAttributes: { "data-abide": true }, 
                          instructionsBelowField: true, 
                          submitClass: "button", 
                          returnUrl: "/contact", 
                          useRequiredAttribute: true
                      }
                  ).render() }}
  
              {% endif %}
  </code></pre>
  
  <p><a href="https://solspace.com/craft/freeform/docs" rel="nofollow noreferrer">https://solspace.com/craft/freeform/docs</a></p>
  
  <p><strong>Update:</strong> Working code using query param instead. Thanks @Jan_dh.</p>
  
  <pre><code>            {% if craft.request.getQuery('success') == 1 %}
  
                  &lt;div class="callout success"&gt;Your message has been sent.&lt;/div&gt;
  
              {% endif %}
  
              {{ craft.freeform.form("contactForm", {
                      formAttributes: { "data-abide": true }, 
                      instructionsBelowField: true, 
                      submitClass: "button", 
                      returnUrl: "/contact?success=1", 
                      useRequiredAttribute: true
                  }
              ).render() }}
  
              {% endif %}
  </code></pre>
  
Tags: <plugin-freeform>
Title: Freeform Success Notice in Template
ThreadText: # Freeform Success Notice in Template
  
  (Asked by: username_0 on 2017-01-29)
  
  I am having trouble getting a freeform success message to display. I am posting back to the same template. What is the proper way to check if the form was posted? I see in the freeform render template there is a freeform.hasErrors, is there something for success perhaps?
  
  ```
              {% if craft.request.getPost('firstName')|length %}
  
                  <div class="callout success">Your message has been sent.</div>
  
              {% else %}
  
                  {{ craft.freeform.form("contactForm", {
                          formAttributes: { "data-abide": true }, 
                          instructionsBelowField: true, 
                          submitClass: "button", 
                          returnUrl: "/contact", 
                          useRequiredAttribute: true
                      }
                  ).render() }}
  
              {% endif %}
  
  ```
  
  <https://solspace.com/craft/freeform/docs>
  
  **Update:** Working code using query param instead. Thanks @Jan\_dh.
  
  ```
              {% if craft.request.getQuery('success') == 1 %}
  
                  <div class="callout success">Your message has been sent.</div>
  
              {% endif %}
  
              {{ craft.freeform.form("contactForm", {
                      formAttributes: { "data-abide": true }, 
                      instructionsBelowField: true, 
                      submitClass: "button", 
                      returnUrl: "/contact?success=1", 
                      useRequiredAttribute: true
                  }
              ).render() }}
  
              {% endif %}
  
  ```
  
  **Tags:** plugin-freeform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-29. Score: 5 | Accepted answer
  
  You can add a param to your `returnUrl` in the form composer then check the template for the param.
  
  For example:
  
  You redirect to `/contact?success`
  
  ```
  {% set successParam = craft.request.getParam('success') %}
  {% if successParam is not null %} 
    <p>Hooray! Success!!</p>
  {% endif %}
  
  ```
  
  Another option is to Ajax submit your form and just have a modal or something on a succes submit. An example of an Ajax submit can be found in the official freeform docs [here](https://solspace.com/craft/freeform/docs/ajax-forms/).
  
  > **Comments:**
  > **username_0**: Thanks. I tried that, and setup a route to use my same contact template and it displayed the success message...the problem with that route is that contact is a single in Craft. So if i access it at contact/success it doesn't have the {{ entry }} fields. Am I doing something wrong? I want to use the same template for contact and contact/success. Perhaps i do need to go the ajax route.  
  > **username_1**: Instead of returning a new segment you can return a param. I'll edit my answer  
  > **username_0**: Great idea. It's fixed. I don't post here often, what is the best way to post the working code?  
  > **username_1**: You can edit your original question with a little note that that is the working code. Welcome to the Craft family ;)  
  > **username_0**: I updated original question with some working code. Thank you.  
  
  ---
  
  