MrSolution MrSolution - 1 year ago 105
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.


if ($scope.currentUser.Login.length != 0) {


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

Can someone help me?

Answer Source

i maked it like this and it works!


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


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

but ty for your help guys!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download