Reputation: 97
Please look my simple form in Stackblitz
https://stackblitz.com/edit/angular-et9uww
My form contains 2 checkboxes if I select one of the checkboxes it will populate one textbox. In my scenario, I have 2 checkboxes and 2 text boxes and one submit button.
NOTE- in my case i have n number of checkbox and child questions
Validation includes -> 2 textbox are mandatory
If the user submits the form without entering textbox it will show the error message.
2.then submit the form it will show the error. that is fine.
But I WANT that second error message display only if the user hit submit button again.
Thanks
Upvotes: 1
Views: 1130
Reputation: 828
Not sure if I got your point, but try this:
add some variable submitCount: number to your component; then everytime you click the submit button, just increase this counter; and finally add to the ngIf of your 2nd textbox 'submitCount > 1 &&' and this should be it?
Upvotes: 0