I have a form in a modal with some required fields, but when I hit submit the form just reloads and I don\'t get any message for validation that I am using for submitting th
You can add "data-dismiss=modal"
to the InfroTextSubmit button, and then use 'return false' on the '#InfroTextSubmit
' click function to prevent the form from closing. If the form is valid you call 'submit()'.
Button code:
Click function:
$('#save').click(function(){
if ($('#myField1').val()==="") {
// invalid
$('#myField1').next('.help-inline').show();
return false;
}
else {
// submit the form here
$('#InfroText').submit();
return true;
}
});
There a several different approaches to the validation itself.
Working on Bootply: http://bootply.com/60244