【发布时间】:2018-02-16 07:55:41
【问题描述】:
我有一个简单的表单,我正在尝试使用 SweetAlert2 让用户在提交和处理表单之前确认他们的提交。
我正在使用下面的代码来中断提交流程,但是无论用户是否按下模式取消点击,表单都会提交。有谁知道我做错了什么?
<script>
$(document).on('click', '#note_submit', function(e) {
e.preventDefault();
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
buttons: true,
dangerMode: true,
icon: "warning",
input: 'checkbox',
inputValue: 0,
showCancelButton: true,
inputPlaceholder: ' I agree with the Terms',
confirmButtonText: 'Continue',
inputValidator: function (result) {
return new Promise(function (resolve, reject) {
if (result) {
resolve();
} else {
reject('You need to agree with the Terms');
}
})
}
}).then(function (result) {
$('#notes_form').submit();
});
});
</script>
【问题讨论】:
-
你使用的是SweetAlert还是SweetAlert2?
标签: javascript sweetalert sweetalert2