ngx-materialize: how to show validation errors on form submit?

352 Views Asked by At

All the examples on the page https://sherweb.github.io/ngx-materialize/form-validation have submit button disabled until form is valid. I would like to make it enabled and show validation errors on submit if there are any.

Is it possible?

2

There are 2 best solutions below

0
On

You can remove [disabled]="form.valid" from the Submit Button Tag. You can control validation when user press submit button.

0
On

You can directly change the value of pristine key of the input field in the form variable just as the user tries to submit the form. If your form is invalid execute this.yourform.get('your_input_field').pristine = false; for invalid field and error messages will be displayed immediately.