Reputation: 57
when no dropdown is selected message comes but when any one or more dropdown is selected then also the message is coming Please select atleast one.Below is my angularjs
$scope.check = function () {
if ($scope.landing.class == null || $scope.landing.class == undefined|| $scope.landing.class == "" && $scope.landing.fueltype == undefined || $scope.landing.fueltype == null || $scope.landing.fueltype == "" && $scope.landing.transmiss == null || $scope.landing.transmiss == undefined || $scope.transmiss == "" && $scope.landing.driving == null || $scope.landing.driving == undefined || $scope.driving == "" && $scope.landing.pick == null || $scope.landing.pick == undefined || $scope.landing.pick == "" && $scope.landing.stat == null || $scope.landing.stat == undefined || $scope.landing.stat == "") {
alert('Please select atleast one')
}
}
Upvotes: 0
Views: 49
Reputation: 1871
You probably need extra parenthesis...
if (($scope.landing.class == null || $scope.landing.class == undefined || $scope.landing.class == "" )
&& (
$scope.landing.fueltype == undefined || $scope.landing.fueltype == null || $scope.landing.fueltype == "" )
&& (....
but in general this is ugly you must find a better/smarter way to do this validation..
Upvotes: 1