<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>

CC BY-SA 3.0
2017-01-29T18:57:46.590Z
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.
Shift2Design
CC BY-SA 3.0
2017-01-29T19:03:20.570Z
Instead of returning a new segment you can return a param. I'll edit my answer
Jan_dh
CC BY-SA 3.0
2017-01-29T19:10:36.497Z
Great idea. It's fixed. I don't post here often, what is the best way to post the working code?
Shift2Design
CC BY-SA 3.0
2017-01-29T19:14:40.407Z
You can edit your original question with a little note that that is the working code. Welcome to the Craft family ;)
Jan_dh
CC BY-SA 3.0
2017-01-29T19:29:33.753Z
I updated original question with some working code. Thank you.
Shift2Design
CC BY-SA 4.0
2017-01-29T18:54:08.997Z
2019-11-25T14:42:15.187Z
2019-11-25T14:42:15.187Z
Jan_dh
<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>

<plugin-freeform>
Freeform Success Notice in Template
# 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 %}

                Your message has been sent.

            {% 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 %}

                Your message has been sent.

            {% 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 %} 
  Hooray! Success!!
{% 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.

> **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.  

---

