js monitors form submission events to prevent repeated form submissions

When calling, use the submit button click event. After listening to submit, the button will be grayed out. You can write the listener event single function as follows
. $('#btn').click(function() {
    var items = {
        inputemail : [{type:'null', errMsg:zhffTip.langs.errTpl.noText.stringFormat('email')}, {type:'email', errMsg: zhffTip.langs.errTpl.shippingAddress.stringFormat('email')}],
        inputname : [{type: 'null', errMsg:zhffTip.langs.errTpl.noText.stringFormat('name')}, {type:'zhoren', errMsg: zhffTip.langs.errTpl.invalidName}],
    };


    return $('#addressEditForm' ).formCheck(items, {
        errinfoFinder: function(obj) { 
            var tip = obj.next("span");
            return tip;
         },
    });
});


//Bind listener event
function addEventHandler(target,type,func){  
    if(target.addEventListener){  
        //监听IE9,谷歌和火狐  
        target.addEventListener(type, func, false);  
    }else if(target.attachEvent){  
        target.attachEvent("on" + type, func);  
    }else{  
        target["on" + type] = func;  
    }   
}  
function eventDis(e,btn){  
     $("#btn").attr("disabled",true); //按钮id
     //e.preventDefault();  //阻止表单提交
}
window.onload = function(){  
    var bindEventBtn = document.getElementById("addressEditForm");  //form 表单id  
    addEventHandler(bindEventBtn,"submit",eventDis); 
};


$(function(){
    eventDis(e,$("#btn"));
})

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325364503&siteId=291194637