0
<td>
  <div>
    <ng-form name="mrpForm">
        <input type="number" min="1" name="mrp" step="any" ng-model="sku.mrp" style="width:80px;" / required>
        <span style="color:red;" ng-if="(mrpForm.mrp.$error.min)">Must be greater than zero</span>
    </ng-form>
  </div>
</td>
<td>
  <ng-form name="packQtyform">
    <input type="number" name="skupackQty" min="2" max="100" ng-model="sku.packQty" style="width:100px;" />
    <span style="color:red;" ng-if="(packQtyform.skupackQty.$error.min)">Must be greater than 1</span>
    <span style="color:red;" ng-if="(packQtyform.skupackQty.$error.max)">Maximum 100</span>
  </ng-form>
</td>
<td>
  <button class="col-md-12 col-sm-12 col-xs-12 btn btn-sm blue" ng-disable="!sku.mrp"
ng-click="addsku(sku);>Save</button>
</td>

In the above code, I want to make save button disable only if a sku.packQty value is an error and if sku.mrp empty,sku.packQty can be empty but it should not be an error If error message save button must be disabled.

2

2 Answers 2

0

You can use form-name.$invalid for this.

<button class="col-md-12 col-sm-12 col-xs-12 btn btn-sm blue" ng-disable="!sku.mrp || mrpForm.$invalid || packQtyform.$invalid"
ng-click="addsku(sku);>Save</button>

I couldn't understand the validation conditions but $invalid would do.

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

1 Comment

If you like the answer, please give upvotes too for answers.
0

I would create a function like:

$scope.valid_form() {
  //here are all the terms, return false if something is wrong
  return true;
}

And then, in my html button I will simply say:

ng-disabled="!valid_form()"

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.