Hi I have a case where I disable the submit button when entering the form and only enable it when the input box has some text.
<div id="app-id-input-container" ng-form="appIdInput">
<div class="input-group">
<input id="app-id-input" name="appIdInput" ng-click="clearAppIdInput()" class="form-control" type="text" ng-model="appId" pattern="^[AaIi][PpXxNn][0-9]{6}$" maxlength="8" />
<span class="input-group-btn">
<button id="addAppId" class="btn btn-success" ng-click="preferences.appIdInput.$valid && addAppId()" type="button"> <span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
<span class="validation-alert" ng-show="appIdError">{{appIdError}}</span>
</div>
I clear the field when a user clicks inside the input box.
$scope.clearAppIdInput = function() {
$scope.appId = "";
};
Even though the scope is empty, the button is not disabled.
This is how I disable the button.
$(document).ready(function(){
$('#addAppId').prop('disabled',true);
$('#app-id-input').keyup(function(){
$('#addAppId').prop('disabled', this.value == "" ? true : false);
});
});
Right now, I can disable the button again by clicking on "backspace" on my keyboard?
How do I disable the button again just when I clear the input field using a click?