Anup
Anup

Reputation: 9738

AngularJs - Make form valid manually

I have form with multiple textboxes. If user leaves a field blank he will be shown a checkbox under the form, if the user selects the checkbox then form can be submitted inspite of fields empty.

So for checkbox click, i have to make the form valid manually.

I tried doing form.$valid = true; but doesn't give me proper results.

Have any idea How to make form valid manually.

Upvotes: 1

Views: 147

Answers (1)

Brocco
Brocco

Reputation: 64883

Angular provides this functionality to you via method on the form object that gets created.

$valid is a boolean, meant to be used as a read-only value.

If you would like to force the form to be valid, use $setValidity

from the documentation:

Change the validity state, and notifies the form when the control changes validity. (i.e. it does not notify form if given validator is already marked as invalid).

This method should be called by validators - i.e. the parser or formatter functions

Upvotes: 6

Related Questions