2

My app has a stepper, one of the steps has 2 forms inside it, Main form and another form. The main form is the form that is required for the step control. The other form is optional (but still I want to validate the input if the user enters any input). Both forms are reactive forms.

The problem is that when I try to move to the next step in the stepper, the other form, is being validated and showing all the errors (though it's not the step control).

The desired behavior that I wish is that when I click the next step it wont affect the other form, and only validate the main form, what can I do in order to achieve it?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Breeze Kay
  • 21
  • 1
  • 1
  • 2
  • 1
    Welcome to SO! Please remember to include a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). Such as what you've tried so far, what failed, what research you did. – Johan Rin Dec 22 '18 at 11:15

1 Answers1

2

see this stackblitz example.

you can validate forms and prevent for switching between <mat-step>s, until errors disappear.

Amir Azizkhani
  • 1,662
  • 17
  • 30