1

I read on How to make a formControl readonly that the best way to obtain a readonly input with Reactive Forms in Angular is to use specificFormControl.disable()

That cause me a problem because I want also to use validator of this input, but .disable() make my input always as VALID

As workaround I use readonly in my .html file. Unfortunatelly, for calendar and radiobutton input it's not working and force me to use the disabled attribute with following warning in console by using reactive forms with disabled attribute.

There's a workaround that fix this?

Luca Angrisani
  • 359
  • 3
  • 13
  • Why would you want to validate a readonly control? The point of using a validator is to verify what the user entered. What are you trying to do exactly? – ukn Jan 26 '22 at 14:58
  • The case is: I have 2 input and if the value of the first is a certain value, the second is compiled with other certain value programmatically and the second one have to become readonly. After that i have to be sure of the validation of the second input – Luca Angrisani Jan 26 '22 at 15:03
  • you can always turn the 2nd field into an textbox instead of disabling it and do a crossfield validation to know if the form is valid. Having the readonly field not showing will not disable the validation and will still be available from the ts file. – ukn Jan 26 '22 at 15:18
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 04 '22 at 03:19

0 Answers0