0

I'm writing a form where a user can add multiple credit card information, similar to this one:

<form name="newCard">
    <label for="surname">Card number: </label> 
    <input type="text" ng-model="formCard.code" required name="code" />

    <label for="surname">CVV: </label> 
    <input type="text" ng-model="formCard.cvv" required name="cvv" />

    <input type="button" value="Add Card" />
    <input type="button" value="Save" />
</form>

The "Add card" button adds the validated current card data to a js array in my controller.

I would like the "Save" button to be disabled unless this array is populated. How can I use custom validation in Angular to achieve this?

1 Answer 1

1

Bind your array to the scope. Then :

<input type="button" value="Add Card" ng-disabled="!yourJsArray.length" />
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.