Kamil Zielinski
Kamil Zielinski

Reputation: 171

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

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?

Upvotes: 1

Views: 344

Answers (2)

Gaurav Singh
Gaurav Singh

Reputation: 65

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.

Upvotes: 0

Suresh Kumar Ariya
Suresh Kumar Ariya

Reputation: 9764

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

Upvotes: 0

Related Questions