wzCommon.checkRequired = function (parent, errorStr, fn) {
var required = parent.find('.required'),
oNumber = parent.find('.number'),
oTel = parent.find('.tel'),
flag = true;
if (required.length > 0) {
required.each(function () {
var getVal = $(this).val();
if (getVal === '') {
layer.msg(errorStr, {icon: 2});
flag = false;
return false;
}
});
}
if (oNumber.length > 0) {
oNumber.each(function () {
var verifyNumber = $(this).val();
if (isNaN(verifyNumber)) {
layer.msg(errorStr, {icon: 2});
flag = false;
return false;
}
});
}
if (oTel.length > 0) {
oTel.each(function () {
var getVal = $(this).val();
debugger;
if (!wzCommon.isPhoneNo(getVal)) {
layer.msg(errorStr, {icon: 2});
flag = false;
return false;
}
});
}
if (flag) {
fn();
}
return true;
};
我的思路是这样,但是不清除怎么写
wzCommon.checkStr = function (obj, errorStr, fn) {
if (obj.length > 0) {
obj.each(function () {
var getVal = $(this).val();
if (这里是不同条件) {
layer.msg(errorStr, {icon: 2});
flag = false;
return false;
}
});
}
if (flag) {
fn();
}
return true;
};
雷雷
required =parent.find('.required'),
雷雷 雷雷