MrSolution MrSolution - 5 months ago 32
AngularJS Question

How can I check if the input field is not empty

I need to check that my input field is not empty.

I tried the following but it's not working.

JavaScript:

if ($scope.currentUser.Login.length != 0) {
console.log($scope.currentUser.login.length);
}


HTML:

<div class="cClearFloat cInputSpace">
<input placeholder="login" ng-model="currentUser.login">
</div>


Can someone help me?

Answer

i maked it like this and it works!

JavaScript:

        $scope.showAlert = function() {
            //überprüfen ob die textfelder leer sind
            if ($scope.currentUser.isAdmin == 'Ja' | $scope.currentUser.isAdmin == 'ja') {
                $scope.isAdmin = "Ja";
                $scope.saveUser();
            } else if($scope.currentUser.isAdmin == 'Nein' | $scope.currentUser.isAdmin == 'nein') {
                $scope.isAdmin = "Nein";
                $scope.saveUser();
            } else {
                alert("Bitte geben Sie ein ob der Benutzer ein Admin ist oder nicht!", "Fehler");
            }
        }

HTML:

 <button class="cButtonSpeichern" ng-click="showAlert()">Speichern</button>

but ty for your help guys!

Comments