ui-validate icon indicating copy to clipboard operation
ui-validate copied to clipboard

validating when required = false, and ng-disabled true

Open phazei opened this issue 9 years ago • 4 comments

The issue can be seen in this plunker:

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

phazei avatar Feb 18 '16 00:02 phazei

Working as expected for me.

thetrevdev avatar Feb 25 '16 19:02 thetrevdev

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

phazei avatar May 28 '16 00:05 phazei

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.

thetrevdev avatar Jun 21 '16 17:06 thetrevdev

oh fiddle sticks, duh, sorry about that

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

phazei avatar Jun 21 '16 21:06 phazei