调用时用提交按钮click 事件,监听提交后按钮变灰可将监听事件单写函数 如下
$('#btn').click(function() {
var items = {
inputemail : [{type:'null', errMsg:zhffTip.langs.errTpl.noText.stringFormat('邮箱')}, {type:'email', errMsg: zhffTip.langs.errTpl.shippingAddress.stringFormat('邮箱')}],
inputname : [{type:'null', errMsg:zhffTip.langs.errTpl.noText.stringFormat('姓名')}, {type:'zhoren', errMsg: zhffTip.langs.errTpl.invalidName}],
};
return $('#addressEditForm').formCheck(items, {
errinfoFinder: function(obj) {
var tip = obj.next("span");
return tip;
},
});
});
//绑定监听事件
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"));
})
$('#btn').click(function() {
var items = {
inputemail : [{type:'null', errMsg:zhffTip.langs.errTpl.noText.stringFormat('邮箱')}, {type:'email', errMsg: zhffTip.langs.errTpl.shippingAddress.stringFormat('邮箱')}],
inputname : [{type:'null', errMsg:zhffTip.langs.errTpl.noText.stringFormat('姓名')}, {type:'zhoren', errMsg: zhffTip.langs.errTpl.invalidName}],
};
return $('#addressEditForm').formCheck(items, {
errinfoFinder: function(obj) {
var tip = obj.next("span");
return tip;
},
});
});
//绑定监听事件
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"));
})