且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery,禁止输入表单提交但允许通过单击按钮提交表单

更新时间:2022-12-11 14:58:31

我找到了解决方法

$("#toteform").submit(function(e) {
    if (e.originalEvent.explicitOriginalTarget.id == "submit") {
        // let the form submit
        return true;
    }
    else {
        //Prevent the submit event and remain on the screen
        e.preventDefault();
        return false;
    }
});