Check if a input box is empty

后端 未结 6 1501
南旧
南旧 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:36

    Quite simple:

    
    Please enter something!
    Good boy!
    

    You could also use ng-hide="somefield.length" instead of ng-show="!somefield.length" if that reads more naturally for you.


    A better alternative might be to really take advantage of the form abilities of Angular:

    Please enter something! Good boy!

    Updated Plnkr here.

提交回复
热议问题