0

I have an input field that is disabled and required, the value of this is prepopulated but still, i am getting invalid form control while submission.

<input type="text" name="plantCode" id="plantCode" #plantCode="ngModel"
                      [(ngModel)]="runningRecordModel.plantCode" class="form-control" disabled required />

enter image description here

Miran Parkar
  • 1,523
  • 1
  • 10
  • 13

1 Answers1

0

It's because when you use disabled then value is marked as null. Which get in conflict with your required condition.

Instead of use disabled, you should use readonly.

  1. If you use template driven forms, just use readonly attribute.
  2. If you use reactive forms, here are some workarounds for you: How to make a formControl readonly
georgeos
  • 2,351
  • 2
  • 24
  • 28