1

There's one field in the form which has strict format (validator is already in place).

How to make form submit automatically in AngularJS as soon as it becomes valid?

1 Answer 1

4

I am assuming you are talking about ajax post of form data (model data).

You can do a $watch on the $valid property of a form field and submit the form as soon as it becomes true.

See my fiddle here

Something like

 $scope.$watch('myForm.userName.$valid',function(newValue,oldvalue) {
        if(newValue) {
            alert('Model is valid');
            //Can do a ajax model submit.
        }

    });

You can get mode details from the form directive documentation

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.