当我提交表格时,我正在检查验证。如果验证true
,那么我需要显示确认。目前,它没有显示。验证true
未显示确认时,表单已提交。
这是我的js代码:
$(document).ready(function () {
$('#reason').keyup(function () {
var val = $('#reason').val();
if (val == null || val == "") {
$('#reason_error').html('Please provide a reason.');
validation = false;
} else {
$('#reason_error').html('');
}
});
});
function finishCancelValidate() {
var validation = true;
var val = $('#reason').val();
if (val == null || val == "") {
$('#reason_error').html('Please provide a reason.');
validation = false;
} else {
$('#reason_error').html('');
}
if (validation) {
//alert('hi');
jQuery.confirm({
text: "Do you want to proceed this ?",
confirm: function () {
console.log("You just confirmed.");
return false;
},
cancel: function () {
console.log("You just cancel.");
}
});
} else {
return validation;
}
}
这是表单标记:
<form method="post" class="register" action="finishController.php?a=cancel" name="cancel" onsubmit="return finishCancelValidate();" enctype="multipart/form-data">