jquery确认不能在js函数中工作

时间:2016-09-24 04:33:11

标签: javascript php jquery validation

当我提交表格时,我正在检查验证。如果验证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">

0 个答案:

没有答案