Check if a input box is empty

后端 未结 6 1497
南旧
南旧 2020-12-08 01:48

How can I check if a given input control is empty? I know there is $pristine property on the field which tells that if a given field is empty initially but what

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 02:25

    Another approach is using regex , as show below , you can use the empty regex pattern and achieve the same using ng-pattern

    HTML :

     
     
    Please enter! great!

    Controller:@formController :

    var App = angular.module('app', []);
    App.controller('formController', function ($scope) {              
      $scope.mypattern = /^\s*$/g;
    });
    

提交回复
热议问题