0
I have a form like this
<form action="envia-contato.php" method="post" >
<label>Nome<span style="color:#db0012 !important;">*</span></label>
<input type="text" name="nome" id="nome" />
<label>E-mail<span style="color:#db0012 !important;">*</span></label>
<input type="text" name="email" id="email" tabindex="2" />
<label>Telefone</label>
<input type="text" name="telefone" id="telefone" tabindex="3" />
<label class="mensagem">Mensagem<span style="color:#db0012 !important;">*</span></label>
<textarea name="mensagem" id="mensagem" tabindex="4" ></textarea>
<label id="aviso" class=""><p></p></label>
<input type="submit" class="btEnviar" value="Enviar" tabindex="6" />
</form>
how caught the successful message return from php to jquery to show the successfully sent email message.
$(document).ready(function() {
$("#aviso").hide();
$("form").submit(function() {
var checar = 0;
if($("#nome").val() == "") { checar = 1; }
else if($("#email").val() == "") { checar = 1; }
else if($("#mensagem").val() == "") { checar = 1; }
if (checar == 1) {
$("#aviso").removeClass('sucesso');
$("#aviso").addClass('erro');
$("#aviso p").text('Os campos marcados com * s\u00e3o obrigat\u00f3rios.');
$("#aviso").fadeIn();
return false;
}
});
});
Daniel edits there your question that could not understand anything you want to do!
– LeAndrade
If clicking send shows message ( the fields * are empty) I want that when click send if you have filled the fields send the data pro php, ( ate ai all right) but return to the form and show the message success in the warning field.
– Daniel dalla colletta
I think it is not possible to do this, because when you give the Ubmit the request will go to another page and the one you were is closed
– Ademilson Santana da Silva
You can use ajax to do that. There’s a lot here on Sopt and Google about that.
– Andrei Coelho