If the user does't fill in all the fields properly, an error block shows up with all the errors. At the moment if they click submit again, the error message stays there while the little loader spins round and submits the form again. I tried to hide the error message but it hid the message even on initial submit which isn't right. It just needs to hide the error message if it is visible.
$.ajax({
type: "POST",
url: "process.php",
data: str,
beforeSend: function() {
$("#contact-submit").hide();
$("#loading").show();
},
success: function(response) {
$('#error').html(response);
if (!response || response.length == 0 || response.indexOf("Your message was sent") >= 0)
$("#contact-form").hide();
$("#contact-submit").show();
$("#loading").hide();
Aucun commentaire:
Enregistrer un commentaire