【发布时间】:2016-12-27 01:55:46
【问题描述】:
我有一个包含 6 个输入的表单,输入按两个分组,我使用 this fiddle 中的复选框启用/禁用它们。
如何限制搜索?例如,如果用户选择了 check1 复选框,或者他们选择了复选框 check1 和 check2,我需要让用户知道他们需要填写两个输入em> 他们需要填写所有 4 个输入。现在我有这个:
if( (check1.checked || check2.checked || check3.checked) ){
if($scope.tolPositivaDim1 == '' || $scope.tolNegativaDim1 == '' ||
$scope.tolPositivaDim2 == '' || $scope.tolNegativaDim2 == '' ||
$scope.tolPositivaDim3 == '' || $scope.tolNegativaDim3 == ''){
console.log(''Need to fill all inputs);
} else
console.log('Something');
} else {
console.log('Need to check at least one');
}
但是有了这个,直到我填写了六个输入,它才让我搜索。有没有办法不用if为每个具体案例做这个?:
if(check1.checked) || if(check1.checked && check2.checked).....
【问题讨论】:
标签: javascript html angularjs forms