Reputation: 562
I'm working with Semantic Ui Forms but I can't figure out how to prevent form submission after form validation.
I can't find anything in their documentation… thanks a lot.
This is my current submission script:
$(function () {
$('#formId').on('submit', function (e) {
e.preventDefault();
$.ajax({
type: 'post',
url: 'phpScriptUrl.php',
data: $('form').serialize(),
success: function () {
//"ok" label on success.
$('#successLabel').css("display", "block");
}
});
});
});
Upvotes: 2
Views: 4106
Reputation: 175
Using callbacks. I added some form validation as example
$('.ui.form').form({
fields: {
firstname : 'empty',
lastname : 'empty'
},
onSuccess: function(event, fields) {
event.preventDefault();
$.ajax({
type: 'post',
url: 'phpScriptUrl.php',
data: $('form').serialize(),
success: function () {
//"ok" label on success.
$('#successLabel').css("display", "block");
}
});
}
})
;
Upvotes: 7