I have one FormGroup, once the user is submitted and form has some error, I make submitted variable to true and shows the error, after that, if the user make any changes in the form the submitted variable should be false and hide the errors.
Is there any way how I can do this? I am able to change the submitted variable to true, if the form has error and it is submitted, but if the user make any changes to the form after submittion, how I can set the submitted variable to false?
According to your discription the error messages display after submit.
it’s hard to maintaint the state of your form with your approche.
but you can use tricks like this :
You can try another way :
Instead of display error after submit, you can benefit from reactive forms and display error instantaneous for each field of your form and the submit button can only be enabled if the from is valid.
N.B : if the error messge is from the backend side you can use à toast or snackbar.
Answered By – Souhail Chougrani
Answer Checked By – David Marino (BugsFixing Volunteer)