Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,

i want to disable my input submit for the first it works nice, i want to disable my input after adding same one this is my code it works fine

Html :

<form class="form-horizontal col-md-6" role="form" name="frm">

<label class="control-label col-sm-2" for="Firstname">Prénom:</label>

<input type="text" ng-minlength="4" class="form-control filters" name="Firstname" ng-model="firstname" required autofocus>
Ce champ et obligatoire!
Trop court!





<label class="control-label col-sm-2" for="Lastname">Nom</label>

<input type="text" ng-minlength="4" class="form-control filters" name="Lastname" ng-model="lastname" required>
Ce champ et obligatoire!
Trop court!



<button type="submit" class="btn btn-success" ng-click="Add(false)" ng-disabled="frm.$invalid">Ajouter</button>

</form>
AngularJS:

app.controller('UserAdminAddController', function ($scope, httpService) {

$scope.Add = function () {
var data = {
firstname: $scope.firstname,
lastname: $scope.lastname
};
var log = httpService.request('api/User/AddUserByForm/', 'put', data);
log.then(function (result) {
if (result.data.Status == 'Succeed') {
$("input[name='Firstname']").val(null);
$("input[name='Lastname']").val(null);
$('#Succeed').fadeIn();
$('#Succeed').delay(3000).fadeOut(); }
else {

}

});
}
};
});

css:
input.ng-invalid.ng-dirty{border:1px solid red;}

What I have tried:

For the first time i have user ng-disabled="frm.$invalid" for my submit buton
Posted
Updated 23-Feb-16 23:56pm

1 solution

hi,
i have resolved, i have add
$("#addBtn").attr('disabled', 'disabled');
in my controller and it work thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900