I am trying to disable my Login button, when nothing is present in the form fields. I am already using ng-disabled, could any body help why it is not getting disabled. Find the sample code below: I have checked in previous posts but the code written there is almost the same as that to the format. I am still not able to disable it
<b>
<form role="form" name="form" id="form" ng-submit="loginValidate()">
<div class="jumbotron">
<div class="form-group">
<label>Username </label> <input class="form-text" type="text" ng-model="username" name="username" />
</div>
<div class="form-group">
<label>Password </label> <input class="form-text" type="text" ng-model="password" name="password" />
</div>
<div>
<p>
<button type="submit" class="btn btn-primary"
ng-click="submitted=true" ng-disabled="form.$invalid">Login</button>
</p>
</div>
</form>
<b>
The form defined here is a simple form, yet i am not able to disable the Login button
Probably you missed to use "required"
tag in input fields!
try like below once
<b>
<form role="form" name="form" id="form" ng-submit="loginValidate()">
<div class="jumbotron">
<div class="form-group">
<label>Username </label> <input class="form-text" type="text" ng-model="username" name="username" required />
</div>
<div class="form-group">
<label>Password </label> <input class="form-text" type="text" ng-model="password" name="password" required />
</div>
<div>
<p>
<button type="submit" class="btn btn-primary"
ng-click="submitted=true" ng-disabled="form.$invalid">Login</button>
</p>
</div>
</form>
<b>