I'm using Angular 2 Reactive Form. I have a form Control which is defined with required validation. When the user loads the form and this control is populated Angular consider the form control as valid. (Which is good!)
However, if the form control is populated and it's also disabled angular consider it as invalid? (W-H-Y?)
Have anyone encountered this? Is this a bug or by design?
Thanks!
Every time the value of a form control changes, Angular runs validation and generates either a list of validation errors that results in an INVALID status, or null, which results in a VALID status.
This is by design, as per the W3C standard disabled inputs are not valid. In Angular you can use FormGroup.getRawValues()
if you want to retrieve all values regardless of whether they are disabled or not.
Alternatively consider using the readonly
attr instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With