1

Append user email in Display message after form submit

  1. 2 months ago

    I notice that many user just enter wrong mail by mistake. Eg. 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????

    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/ My fb: https://fb.com/fususuvn

  2. 7 weeks ago

    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.

    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

    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/ My fb: https://fb.com/fususuvn

  3. Edited 7 weeks ago by Francesco

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

  4. Edited 7 weeks ago by fususu

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

  5. fususu

    Oct 21 Answer
    Edited 7 weeks ago by fususu

    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/ My fb: https://fb.com/fususuvn

 

or Sign Up to reply!