0
I am trying to validate the existence of a class in 3 ids to return a text that will be inserted in a p after clicking the send button of a form. I inserted the onclick in the button having the function as value. I don’t know where I’m going wrong, but even the class existing the value I want in p is not passing.
button:
<button onclick="mensagemerro()" type="submit" name="mauticform[submit]" id="mauticform_input_teste_submit" name="mauticform[submit]" value="" class="mauticform-button btn btn-default" value="1">EXPERIMENTE GRÁTIS</button>`
div with p and Function:
<div class="ajuste-resposta-form">
<p id="resposta"></p>
<script>
function mensagemerro() {
var nome = $("#mauticform_teste_nome").hasClass("mauticform-has-error");
var email = $("#mauticform_teste_email").hasClass("mauticform-has-error");
var telefone = $("#mauticform_teste_telefone").hasClass("mauticform-has-error");
if (nome || email || telefone == true) {
texto = "O preenchimento dos campos abaixo é obrigatório";
}
document.getElementById("resposta").innerHTML = texto;
}
</script>
</div>
The form is submitted even with errors or this mautic cancels the submission?
– LeAndrade
The mautic itself cancels the shipment.
– A. Halasz