My form is always being sent, even if there is nothing in the input, can someone give me a light?
HTML:
<form id="ajax" method="post">
<div class="form-group">
<input type="text" name="name" class="form-control required" placeholder="Nome">
</div>
<div class="form-group">
<input type="email" name="email" class="form-control required" placeholder="E-mail">
</div>
<div class="form-group">
<input type="text" name="phone" class="form-control required" placeholder="Telefone (com DDD)">
</div>
<div class="form-group">
<input type="text" id="autocomplete" name="city" class="form-control required" placeholder="Cidade"/>
</div>
<div class="form-group">
<input type="text" class="form-control required" name="zip_code" placeholder="Compra, construção, quitar financiamento?">
</div>
<input type="submit" class="btn btn-default quote_btn" value="Solicitar proposta">
</form>
JS:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><scripttype="text/javascript">
$(document).ready(function(){
$('#ajax').submit(function(){
var dados = $( this ).serialize();
$.ajax({
type: "POST",
url: "lead.php",
data: dados,
success: function( data )
{
alert('Enviado com sucesso');
}
});
return false;
});
});
</script>