Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Angular FormGroup touched not working for checkbox

Angular form for checking form is touched not working with the checkbox. I got !newDeviceGroup.touched = true even though the checkbox is changing its value when I am clicking. Not sure why?

<form [formGroup]="newDeviceGroup" (ngSubmit)="onSubmit()">
  <div class="row">
    <div class="col">
      <label class="chk-container" for="isNewDevice"
        ><span class="chk-label">Device is work</span>

        <input
          type="checkbox"
          id="isNewDevice"
          name="isNewDevice"
          class="isNewDevice"
          [value]="isDeviceWork"
          [checked]="isDeviceWork == true"
          (change)="onCheckChange($event)"
        />
        <span class="checkmark"></span>
      </label>
    </div>
  </div>
<button type="submit" class="btn btn-primary" id="btnSubmit" [disabled]="!newDeviceGroup.touched">
</form>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need set the FormGroup as touched via AbstractControl.markAsTouched().

onCheckChange(event: any) {
  this.newDeviceGroup.markAsTouched();
}

Sample Demo on StackBlitz

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!