jQuery:提交表单前判断表单是否被修改过

时间:2023-03-09 17:46:29
jQuery:提交表单前判断表单是否被修改过

表单加载完成后执行 :

   //表单中包含input(text,checkbox,hidden),select,radio,

    $("#editWithdrawAutoApprovedConfig :input,#editWithdrawAutoApprovedConfig :checkbox,#editWithdrawAutoApprovedConfig :radio,#editWithdrawAutoApprovedConfig select").change(function() {
             $("#editWithdrawAutoApprovedConfig").data("changed",true);
        });

提交表单时执行:

if (!$("#editWithdrawAutoApprovedConfig").data("changed")) {
            alert("表单未做任何修改!");
            return false;
        }