I am trying to validate the existence of a class in 3 ids to return a text that will be inserted into a p after clicking on the submit button of a form. I inserted the onclick button with the function as value. I do not 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>