I am playing a little bit with bootstrap and bootstrapvalidator to validate my forms. Everything works fine, but now I want to make an alert show up, that the message was send successfully (or redirect to a success.html page). Here is the html code as an example:
HTML:
<form id="order">
<input type="text" name="name"/><br>
<input type="text" name="email"/><br>
<textarea name="comment"></textarea><br>
<button type="submit" name="send" id="send">Send</button>
<div class="alert alert-success" id="asked">
<strong>Success!</strong> Indicates a successful or positive action.
</div>
</form>
Here is a snippet of the validation jquery code:
JQUERY:
$(document).ready(function() {
var validator = $('#order').bootstrapValidator({
fields: {
email : {
message : "Please insert Email",
validators : {
notEmpty : {
message : "Insert a valid email address"
},
stringLength : {
min : 6,
max: 35,
}
}
}
}
});
});
What also worked for me is to hide the alert and show after the button was clicked:
JQUERY:
$(document).ready(function(){
$("#asked").hide();
});
$('#send').click(function() {
$.post('php/text.php', $('form#order').serialize());
$("#asked").show();
});
Now I want to make the alert show up, if everything in the validation is green. Even the $.post method worked only after the validation is successful. How can I achieve the same with the alert message? Thanks in advance!