0

I need one help.I need to disable some of my input field when radio button will select.Let me to explain my code below.

<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Unit Cost Price :</span>
<input type="text" name="discount" id="ucp" class="form-control" placeholder="Add unit cost price" ng-model="unit_cost_price" ng-keypress="clearField('ucp');" ng-readonly="ucpread" ng-disabled="ucpdis">
</div>
<div class="input-group bmargindiv1 col-md-12" >
<input type="radio" name="favoriteColors" ng-model="isChecked.new">Add new stock
<input type="radio" name="favoriteColors" ng-model="isChecked.old">Update stock 
</div>

In the above code i am getting Update stock is by default selected.I need when user will choose Update stock the above Unit Cost Price field will be disabled/readonly when user will choose Add new stock it will be enable.Please help me.

2
  • try ng-disabled="isChecked.new" Commented Dec 30, 2015 at 12:45
  • I tested but its not coming. Commented Dec 30, 2015 at 12:48

1 Answer 1

3

Give value to radio button and compare it to disable\enable text

 <input type="radio" ng-model="isChecked" name="favoriteColors" value="true" />Add new stock
 <input type="radio" ng-model="isChecked" name="favoriteColors" value="false" />Update stock

 <input type="text" ng-disabled="isChecked=='false'">

Check this fiddler : http://jsfiddle.net/ryf2h49p/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.