I have a form with two states. In first state required inputs are fill and in the second state are empty. I use sweet alert to show result of input, but if-else don´t work properly. My form code is
<link rel="stylesheet" type="text/css" href="http://ift.tt/1EUgO2B"/>
<form method='post'>
<input type="text" name="nombre" id="nombre" autofocus required placeholder="Escribe tu nombre (Obligatorio)"/>
<br>
<input type="mail" name="mail" id ="mail" required placeholder="Escribe tu correo (Obligatorio)">
<br>
<input type="tel" name="telefono" placeholder="Escribe tu teléfono" />
<br>
<textarea rows="5" cols="35" name="mensaje" id="mensaje" required placeholder="Escribe tu mensaje (Obligatorio)" /></textarea>
<br>
<input type="submit" id="enviar" value="Enviar" />
</form>
And my jquery code
<script src="http://ift.tt/1yCEpkO"></script>
<script src="http://ift.tt/1EUgO2F"></script>
$("#enviar").click(function () {
if ($("#nombre").is(':empty')){
swal({
title: "Datos incorrectos.",
text: "No se ha enviado el correo.",
type: "warning",
allowOutsideClick: false,
timer:5000,
});
}
if ($("#nombre").not(':empty')){
swal({
title: "Correcto.",
text: "Se ha enviado el correo.",
type: "success",
allowOutsideClick: false,
timer:5000,
});
}
});
Any idea?
Aucun commentaire:
Enregistrer un commentaire