Reputation: 4878
I want to only enable my button if the textfield have input but I can't get ng-disabled
to work:
<form novalidate>
<button type="submit" ng-click="add('+')" ng-disabled="bittext.$invalid">Done</button>
<textarea type="text" ng-model="bittext" size="30" placeholder="add bittext here" style="width: 212px; height:100px" required=""></div>
</form>
But when I tried(without the $invalid
)
<form novalidate>
<button type="submit" ng-click="add('+')" ng-disabled="bittext">Done</button><!-- no '.$invalid'-->
<textarea type="text" ng-model="bittext" size="30" placeholder="add bittext here" style="width: 212px; height:100px" required=""></div>
</form>
it will disable my button when I input something in the text field.
Upvotes: 0
Views: 1369
Reputation: 112
your using form so you can try like this also
<form name="form" novalidate>
<button type="submit" ng-click="add('+')" ng-disabled="form.$invalid">Done</button>
<textarea type="text" ng-model="bittext" size="30" placeholder="add bittext here" style="width: 212px; height:100px" required=""></textarea>
</form>
Upvotes: 0
Reputation: 282
try ng-disabled="!bittext" . Also in your first paste you have bit text (space). That may be why it wasn't working.
Upvotes: 2