First of all the site is http://emiralmedia.com/site/tennishero, it's just for testing the site before launching it on a separate domain.
Hi, I want to change the response error from a CRM contact form which with stackoverflow help I managed to integrate it in WordPress. The form is linked with a JavaScript to integrate the messages sent from the WordPress site form with another platform. (Client relations management). Now I have this code of the contact form:
<div class="main-content">
<div class="form-mini-container">
<form FormHash="29074-1vmo1w4eti26ekzhtj8e" action="https://r3.minicrm.ro/Api/Signup" method="post" class="form-mini">
<div class='form-row'>
<input name="Contact[1181][LastName]" id="Contact_LastName_1181" language="RO" type="text" placeholder="Name and surname" />
</div>
<div class='form-row'>
<input name="Contact[1181][Phone]" id="Contact_Phone_1181" language="RO" type="text" placeholder="Phone" />
</div>
<div class='form-row'>
<input name="Contact[1181][Email]" id="Contact_Email_1181" language="RO" type="text" placeholder="Email" />
</div>
<div id="Response_29074-1vmo1w4eti26ekzhtj8e" style="display: none;" class="Response raspuns"></div>
<input id="Submit_29074-1vmo1w4eti26ekzhtj8e form-row form-last-row" type="Submit" value="LET´S GET IN TOUCH" class="button2">
</form>
</div>
</div>
When I want to send a message with contact form and I forget to add the "Name" , "Phone" or "Email" , it's sending me the ResponseError in other language for example:
<span class="ResponseError" style="transition: none; line-height: 0px; border-width: 0px; margin: 0px; padding: 0px; letter-spacing: 0px; font-weight: 400; font-size: 14px;">Name and surname este obligatoriu</span>
I want to change the message with my custom one... not with the default one from CRM. The span appears when you try to send the message. From the JavaScript I guess. https://r3.minicrm.ro/api/minicrm.js?t=1470730609
I've tried to make this script, but this did nothing.
if (window.location.pathname == '/site/tennishero/') {
jQuery('.Response span').each(function() {
if (jQuery(this).text() == 'Name and surname este obligatoriu') jQuery(this).text('Name si required');
});
}
if (window.location.pathname == '/site/tennishero/') {
jQuery('.Response span').each(function() {
if (jQuery(this).text() == 'Telefon este obligatoriu') jQuery(this).text('Phone is required');
});
}
if (window.location.pathname == '/site/tennishero/') {
jQuery('.Response span').each(function() {
if (jQuery(this).text() == 'Email este obligatoriu') jQuery(this).text('Email is required');
});
}
Any ideas? Thanks.
Usually, if you want to change the text/html of an element, then you should use innerHTML
(js) or html()
(jquery). In your case, the element is not on the page (it does not exists) when you run that code, it appears after some time, depending on user, so your script won't change anything. Your CRM
script seems to be loaded from external source so, it seems you can't make use of onclick
on the submit button or to edit the message received through ajax. So you can make the script which changes the error message to run at a time interval (in this case, 10 milliseconds, to change the text instantly).
As you are from Romania and we have a specialized team there, there is the translation of the text above:
In mod normal, cand vreti sa modificati continutul unui element de pe pagina, va folositi de innerHTML
in JavaScript sau de html()
in JQuery. In cazul de fata, elementul pe care vreti sa il modificati nu apare odata cu toata pagina, ci atunci cand utilizatorul apasa pe un buton si greseste ceva in formular, deci daca veti rula cand se incarca site-ul ceva gen $(".eroare").html("eroare");
, elementul respectiva nu se va "schimba", fiindca el inca nu exista. Din pacate nu puteti nici simula ceva in genul onclick
, pentru cazul in care vizitatorul apasa butonul de trimitere, nici nu puteti modifica direct codul CRM si mesajul primit prin ajax, fiindca, din cate am observat, scriptul pentru formular este unul extern, care comunica cu serverul (nu am studiat in amanunt). Asadar, o metoda pe care o puteti folosi este aceea de a programa codul care modifica textul sa se repete la un anumit interval de timp, iar daca gaseste acel element cu clasa ResponseError
(din cate am vazut), sa ii schimbe continutul. Acesta ar trebui sa ruleze foarte des, pentru ca utilizatorului sa nu ii apara mai intai textul original iar apoi sa i se schimbe. Codul de mai jos ia toate elementele cu clasa ResponseError
si le modifica continutul, o data la 10
milisecunde. A fost testat pe pagina dvs web.
setInterval(function() {
var response_errors = document.querySelectorAll('.ResponseError');
Array.prototype.forEach.call(response_errors, function(elements, index) {
document.getElementsByClassName("ResponseError")[index].innerHTML="AICI E TEXTUL ERORII";
});
}, 10);
If you have any related question, please leave a comment.