Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

validating when required = false, and ng-disabled true #21

Open
phazei opened this issue Feb 18, 2016 · 4 comments
Open

validating when required = false, and ng-disabled true #21

phazei opened this issue Feb 18, 2016 · 4 comments

Comments

@phazei
Copy link

phazei commented Feb 18, 2016

The issue can be seen in this plunker:

https://plnkr.co/edit/pbLlYkCVTSo1HV8KiXB2?p=preview

@thetrevdev
Copy link
Contributor

Working as expected for me.

@phazei
Copy link
Author

phazei commented May 28, 2016

Leave the box empty, change dropdown from "Everyday" to "Cancel"

Expected behavior:
$scope.testForm.$error is an empty object.
Both "min" and "required" rules disappear from it
Since the field is disabled, no validation rules should be placed on it

Actual behavior:
$scope.testForm.$error is not an empty object.
"required" rule disappears as is standard for validation of disabled fields in angular.
"min" is still listed in the $scope.testForm.$error obj. It shouldn't be there. Once the field is disabled, no validation should be taking place on it, thus there should be nothing in the $error object

@thetrevdev
Copy link
Contributor

The reason you see the required rule disappear is because you have ng-required make it not required when cancelled. This has nothing to do with the input disabled state.
If you change it to just required="true" you will see that the rule still applies even if it is disabled. Its not documented that disabling a field should remove its validation constraints.

@phazei
Copy link
Author

phazei commented Jun 21, 2016

oh fiddle sticks, duh, sorry about that

perhaps a feature request for ui-validate-disable="true" attribute then?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants