I have a form which I am validating using jQuery / PHP. After 50 years of using it, I realized that during validation the field values are erased. How would I keep the values in the fields during validation? Look at the code:
HTML
<form method="post" name="form" novalidate="" id="contact-form">
<div id="success"></div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="Nome" class="form-control" placeholder="Nome *" id="nome" required="required">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="email" name="Email" class="form-control" placeholder="E-mail *" id="email" required="required" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="Telefone" class="form-control" placeholder="Telefone *" data-inputmask="'mask' : '(99)9999-9999'" id="telefone" required="required">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="text" name="Celular" class="form-control" placeholder="Celular *" data-inputmask="'mask' : '(99)99999-9999'" id="celular" required="required">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea name="Mensagem" class="form-control" placeholder="Mensagem *" id="mensagem" required="required"></textarea>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="row">
<div class="col-lg-12 text-center">
<button type="submit" id="submit" class="btn">Enviar</button>
</div>
</div>
</form>
JQUERY
<script type="text/javascript">
$('#submit').click(function() {
$.post("enviar.php", $("#contact-form").serialize(), function(response) {
$('#success').html(response);
$('#nome').val('');
$('#email').val('');
$('#assunto').val('');
$('#mensagem').val('');
});
return false;
});
</script>