# Append user email in Display message after form submit

**URL:** https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628
**Category:** Ideas and Feature Requests
**Created:** [October 4, 2017, 3:15pm UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628 "2017-10-04T15:15:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fususu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fususu/32/215_2.png) [@fususu](https://forum.mautic.org/u/fususu)
#### Post date: [October 4, 2017, 3:15pm UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628/1 "2017-10-04T15:15:50Z")

</div>

I notice that many user just enter wrong mail by mistake. Eg. [myemail@gmai.com](mailto:myemail@gmai.com) - so I think it’s better if after submit the form, Mautic display something like “An email has been sent to {useremail}” to let them know that they have entered the correct email. Or after submit, the email they enter still remain at the input area. How can I do this???

---

<div class="post-metadata">

### Author: ![fususu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fususu/32/215_2.png) [@fususu](https://forum.mautic.org/u/fususu)
#### Post date: [October 4, 2017, 3:15pm UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628/2 "2017-10-04T15:15:50Z")

</div>

I notice that many user just enter wrong mail by mistake. Eg. [myemail@gmai.com](mailto:myemail@gmai.com) - so I think it’s better if after submit the form, Mautic display something like “An email has been sent to {useremail}” to let them know that they have entered the correct email. Or after submit, the email they enter still remain at the input area. How can I do this???

---

<div class="post-metadata">

### Author: ![fususu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fususu/32/215_2.png) [@fususu](https://forum.mautic.org/u/fususu)
#### Post date: [October 20, 2017, 3:47pm UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628/3 "2017-10-20T15:47:16Z")

</div>

After hours of researching, I found a temporary solution: use a javascript to show an alert with user’s email after they submit the form. Here is step-by-step I did to my site. Hope it’s useful for someone 🙂

Step 1. Put the code below in the “form.html.twig” under theme form folder.  
`<script type="text/javascript">
		function Confirm(form){
		m = document.getElementsByName('mauticform[email]')[0].value;
		alert("An email will be sent to *"+m+"* if there is no shark biting the internet cable now!"); 
		form.submit();
		}
	</script>`

Step 2. Edit the submit button in the form, append this the input attributes area.

```auto
onClick="Confirm(this.form)"
```

Then each time user submits that form, an alert box (in web browser style) will appear and show a message that an email will be sent to their email, so they will have a chance to see their email one more time. You can see mine in action here: [https://fususu.com/en/public-speaking-tips/#testform](https://fususu.com/en/public-speaking-tips/#testform)

Step 3. If you have many forms like me and don’t want to edit each form. You can use this query in phpmyadmin.

`UPDATE mtform_fields
SET input_attr = 'class="btn btn-default" onClick="Confirm(this.form)"'
WHERE `type` = 'button'`  
This query will replace the attribute of all submit buttons.

* * *

P.s. I’m not a technical guy, but I’m really good at Googling to fix problem myself. Nice to be here with you guys, let’s make a great community. My blog: [https://fususu.com/en/](https://fususu.com/en/) My fb: [https://fb.com/fususuvn](https://fb.com/fususuvn)

---

<div class="post-metadata">

### Author: ![knishikawa](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@knishikawa](https://forum.mautic.org/u/knishikawa)
#### Post date: [October 20, 2017, 3:54pm UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628/4 "2017-10-20T15:54:38Z")

</div>

a better solution would be to write 2 times email in 2 different fields and check for data before submit form

---

<div class="post-metadata">

### Author: ![fususu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fususu/32/215_2.png) [@fususu](https://forum.mautic.org/u/fususu)
#### Post date: [October 20, 2017, 4:06pm UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628/5 "2017-10-20T16:06:20Z")

</div>

> [@26657:@Francesco](#):
>
> a better solution would be to write 2 times email in 2 different fields and check for data before submit form

I think your solution is useful when user registers an account, they will have enough patience to re-type their email. In my case it’s a subscribe form, I don’t see many sites ask user to re-type their email in a subscribe form.

---

<div class="post-metadata">

### Author: ![fususu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fususu/32/215_2.png) [@fususu](https://forum.mautic.org/u/fususu)
#### Post date: [October 21, 2017, 4:59am UTC](https://forum.mautic.org/t/append-user-email-in-display-message-after-form-submit/9628/6 "2017-10-21T04:59:09Z")

</div>

Today I came to a better solution, that will do exactly what I want. Just put these code in form.html.twig in theme folder, then it will append another message with user email, under Mautic Default Message after submitting a form.

`<div id="mailsent" style="text-align:center;color:green;"></div>
	<script type="text/javascript">
	 function showHide() {
	   m = document.getElementsByName('mauticform[email]')[0].value;		
		document.getElementById("mailsent").innerHTML = "An email will be sent to *"+m+"* Please check carefully!";
	   }
	</script>`

–  
Nice to be here with you guys, let’s make a great community.  
My blog: [https://fususu.com/en/](https://fususu.com/en/) My fb: [https://fb.com/fususuvn](https://fb.com/fususuvn)
