更新时间:2023-02-26 14:23:37
if(!check("#txtName") || !check("#txtRemain") || !check("#txtDw"))
{
return false;
}
confirm("确认添加?")
的代码应该放到外面,checkAll
就应该只做check工作
=================更新的分割线===================
写完之后感觉不太安心,仔细想了想果然:||
的话,如果第一个结果为true,后面的条件都不会执行的,我上面的写法,依然只能显示第一个校验。
function checkAll() {
var checkArr = [check("#txtName"), check("#txtRemain"), check("#txtDw")];
return checkArr.every(function (ele) {
return ele == true;
})
}