在初始化表單的代碼中添加以下加粗部分,有幾個popup就定義幾個標志位,主要是防止第一次失去焦點時候的彈窗(此時還未來得及選擇),提交表單的時候還是會正常校驗的。
//popup觸發失去焦點事件,設置不彈提示窗
var userIdFlag=true;
var userIdFlag2=true;
var appIdFlag=true;
$("#formobj").Validform({
tiptype: function(msg, o, cssctl) {
if(userIdFlag && msg=="請填寫客戶id!"){//不彈提示窗
userIdFlag=false;
return false;
}
if(appIdFlag && msg=="請填寫關聯app!"){//不彈提示窗
appIdFlag=false;
return false;
}
if(userIdFlag2 && msg=="請填寫分析人員id!"){//不彈提示窗
userIdFlag2=false;
return false;
}
if (o.type == 3) {
layer.open({
title: '提示信息',
content: msg,
icon: 5,
shift: 6,
btn: false,
shade:false,time:5000,
cancel: function(index) {
o.obj.focus();
layer.close(index);
},
yes: function(index) {
o.obj.focus();
layer.close(index);
},
})
}
},
btnSubmit: "#btn_sub",
btnReset: "#btn_reset",
ajaxPost: true,
beforeSubmit: function(curform) {
var tag = true;
//提交前處理
return tag;
},
usePlugin: {
passwordstrength: {
minLen: 6,
maxLen: 18,
trigger: function(obj, error) {
if (error) {
obj.parent().next().find(".Validform_checktip").show();
obj.find(".passwordStrength").hide();
} else {
$(".passwordStrength").show();
obj.parent().next().find(".Validform_checktip").hide();
}
}
}
},
callback: function(data) {
if (data.success == true) {
var win = frameElement.api.opener;
win.reloadTable();
win.tip(data.msg);
frameElement.api.close();
} else {
if (data.responseText == '' || data.responseText == undefined) {
$.messager.alert('錯誤', data.msg);
$.Hidemsg();
} else {
try {
var emsg = data.responseText.substring(data.responseText.indexOf('錯誤描述'), data.responseText.indexOf('錯誤信息'));
$.messager.alert('錯誤', emsg);
$.Hidemsg();
} catch(ex) {
$.messager.alert('錯誤', data.responseText + '');
}
}
return false;
}
}
});
});