jenryb
jenryb

Reputation: 2117

Angular validation on form not working

I have a form and I want to check if all the fields are valid or not.

Currently I am using four different methods. Nothing is working. Here is my plunker:

http://plnkr.co/edit/c4czI1W1fvXR4881SP1z?p=preview

Here are the methods I am using to check for validity

<button ng-click="my.$valid && validityCheck()">Update</button>
<div>myForm.$valid = {{myForm.$valid}}</div>
<span ng-show="myForm.$valid" style="color:green">Yippii!</span>
<span ng-show="myForm.$invalid" style="color:red">Not :(</span>

Upvotes: 1

Views: 94

Answers (1)

Win
Win

Reputation: 62260

Plunkder code has few errors.

  • Missing angular script tag
  • ng-click should refer to myForm instead of my. ng-click="myForm.$valid
  • Inject $scope to controller (or use this). function($scope){

http://plnkr.co/edit/Twz9E9LnQ08IpweLARjG

Upvotes: 2

Related Questions