I'm using Liveform service for emailing in my web. right now every time you submit It should alert with a message of fail or success.
While showing fail message works, showing the success message doesn't- since I get redirect before it has the chance to show up. So I need to somehow delay it.
this is my code:
$(document).ready(function() {
$('#emailError').removeClass('active');
$('#contact-form').submit(function(e) {
var email = $('#email').val();
console.log(email);
var message = $('#message').val();
console.log(message);
if (!email || !message) {
alertify.error('Please enter an email and a message');
e.preventDefault();
return;
}
// REDIRECT IN THIS POINT- > HOW TO DELAY HERE?
setTimeout(function() {
alertify.success('SENT SUCCESSFULLY!');
}, 3000);
});
});
<form action="https://liveformhq.com/form/911331a2-0d5e-4fbf-abb0-******" method="POST"
accept-charset="utf-8" id="contact-form">
<input type="email" placeholder="Email..." id="email" name="email" />
<textarea rows="4" cols="50" placeholder="Message..." id="message" name="message"></textarea>
<div class="actions"><button type="submit">Send</button></div>
</form>
How can I make the server wait for some seconds until the alert shows up? As you can see using the timeout as I did didn't work.
thanks