Mark
Mark

Reputation: 1872

Using ng-show with a required attribute

So is there a way that if I have a HTML 5 'required' attribute on an input, that if that input is not shown due to ng-show not triggering it, that this will not fire the 'required' attribute?

Upvotes: 0

Views: 516

Answers (1)

Daniel Flint
Daniel Flint

Reputation: 778

You can use the ngRequired directive.

Although if someone has filled that field out, then changed the form in such a way that it is hidden, the value will still be sent. Using ngDisabled will get around that. You could still use ng-show/ng-hide in combination with that of course.

Demo: http://plnkr.co/edit/NWUiXWQO8oZQVZesblFq?p=preview

Upvotes: 1

Related Questions