Reputation: 2483
I have a form that is using Model Validation, however I need to ask the user a question that only gets asked when the model state is valid and if the user has not changed a value on the form, therefore the user has not changed a default value.
Is it possible that a message can appear on screen to ask the user to confirm (only when model state is valid), No to prevent the form from submitting and agreeing to yes will allow the form to submit?
Upvotes: 2
Views: 55
Reputation: 2483
Many thanks to Stephen Muecke for his solution. I have modified as follows:
$('form').submit(function() {
var checkValue = document.getElementById('amount').value;
if (checkValue == 10000) {
if ($(this).valid()) {
if (!confirm('The amount you are applying for is £10000, are you happy with this amount?')) {
return false;
}
}
}
});
Many thanks Stephen :-)
Upvotes: 0
Reputation:
You could handle the forms .submit()
and test if .valid()
and display a confirm
dialog
$('form').submit(function() {
if ($(this).valid()) {
if (!confirm('Do you accept ...')) {
return false; // cancel the submit
}
}
});
Upvotes: 1