Open Aerendir opened 4 years ago
Hello,
I have exactly the same problem.
I also have the same problem.
Hello... I've found a "workaround" for this bug. This my procedure:
In this way it seems that Mautic do not call the server for fileds validations and it use, instead, your JavaScript code. This is my code, inserted in HTML field of my Mautic module (this is NOT a good JS code, but that's it):
<script>
var formName = 'modulodownloadguidasalento2024';
if (typeof MauticFormCallback == 'undefined') {
console.log('MauticFormCallback UNDEFINED');
var MauticFormCallback = {};
}
var rsm_today = new Date();
var rsm_date = rsm_today.getFullYear()+'-'+(rsm_today.getMonth()+1)+'-'+rsm_today.getDate();
var rsm_time = rsm_today.getHours() + ":" + rsm_today.getMinutes() + ":" + rsm_today.getSeconds();
MauticFormCallback[formName] = {
onValidate: function () {
console.log('START VALIDATION');
document.getElementById('mauticform_modulodownloadguidasalento2024_error').innerHTML = '';
let name = document.getElementById('mauticform_input_modulodownloadguidasalento2024_nome1').value;
let surname = document.getElementById('mauticform_input_modulodownloadguidasalento2024_cognome').value;
let email = document.getElementById('mauticform_input_modulodownloadguidasalento2024_email').value;
let atPosition = email.search("@");
let privacy = document.getElementById('mauticform_checkboxgrp_checkbox_privacy_policy1_10').checked;
if (name.length<3 || surname.length<3 || email.length<10 || atPosition == -1 || !privacy) {
document.getElementById('mauticform_modulodownloadguidasalento2024_error').innerHTML = 'Compila correttamente i campi...';
return false;
} else {
document.getElementById('mauticform_input_modulodownloadguidasalento2024_hiddendate').value = rsm_date;
return true;
}
},
onValidateStart: function () {
document.getElementById('mauticform_input_modulodownloadguidasalento2024_hiddendate').value = rsm_date;
},
};
</script>
I hope this can help someone. Regards.
Prerequisites
Context
I have a page built with Elementor.
Clicking a button, this page opens a popup built with Elementor.
The popup contains a form to compile.
The form is built in Mautic and then embedded in the popup using the Manual Copy.
Error
If I submit the form with empty values Mautic should show an error message under the field (removing the rule display: none from the span used to show the error).
But, instead of doing this, I’m redirected to the same page, but with the error appended as query string.
Something like this:
https://www.example.com/my-page/?mauticError=Errors%3A<br%20%2F>
Expected behavior
The form shows the errors without reloading
Steps to reproduce
It requires an active installation of Mautic.
Isolating the problem
What I tried
Conclusions
I think there is a problem with the Elementor’s Popup JS.
Previewing the popup in Elementor, in fact, the form correctly displays the errors.
Only when I use it in a page the error is displayed.
So it seems the js code that open the popup creates a conflict.
Testing the same form in the Mautic’s preview and in a blank Wordpress post, instead, correctly checks the invalidity of the email and show correctly the errors.
Only when the form is in a popup the error happens.
Environment
System Info
``` == Server Environment == Operating System: Linux Software: Apache MySQL version: MySQL Community Server (GPL) v5.6.47 PHP Version: 7.2.24 PHP Max Input Vars: 12000 PHP Max Post Size: 150M GD Installed: Yes ZIP Installed: Yes Write Permissions: All right Elementor Library: Connected == WordPress Environment == Version: 5.4.1 Site URL: https://www.commercianti.online Home URL: https://www.commercianti.online WP Multisite: No Max Upload Size: 150 MB Memory limit: 1024M Permalink Structure: /%category%/%postname%/ Language: it-IT Timezone: Europe/Rome Debug Mode: Inactive == Theme == Name: eCommerceRS Version: 0.15 Author: Aerendir Child Theme: Yes Parent Theme Name: Hello Elementor Parent Theme Version: 2.3.0 Parent Theme Author: Elementor Team == User == Role: administrator WP Profile lang: it_IT User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 == Active Plugins == Anti-Spam by CleanTalk Version: 5.138 Author: СleanTalk