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

282
Views
How to fix "A form label must be associated with a control" ? ESlint

I have read that htmlFor needs to be added to fix this error, but even with this piece of code, ESlint gives me an error. How can I fix this?

        <input readOnly type="radio" name="slider-2" id="s1-2" checked />
        <input readOnly type="radio" name="slider-2" id="s2-2" />
        <input readOnly type="radio" name="slider-2" id="s3-2" />

        <label type="text" htmlFor="s1-2" id="slide1-2">
          <div className="slider-image">
            <img src={SecendQadroFirst} alt="qadro" />
          </div>
        </label>
        <label htmlFor="s2-2" id="slide2-2">
          <div className="slider-image">
            <img src={SecendQadroSecend} alt="qadro" />
          </div>
        </label>
        <label htmlFor="s3-2" id="slide3-2">
          <div className="slider-image">
            <img src={SecendQadroThird} alt="qadro" />
          </div>
        </label>
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

The attribute you want in the <label> element is simply for, and the value must be the id of the <input> element it is associated with. The input should be after the </label> closing tag

<label type="text" for="s1-2" id="slide1-2">
   <div className="slider-image">
      <img src={SecendQadroFirst} alt="qadro">
   </div>
</label>
<input readOnly type="radio" name="slider-2" id="s1-2" checked>

<label for="s2-2" id="slide2-2">
   <div className="slider-image">
      <img src={SecendQadroSecend} alt="qadro">
   </div>
</label>
<input readOnly type="radio" name="slider-2" id="s2-2">
        
        
<label for="s3-2" id="slide3-2">
   <div className="slider-image">
       <img src={SecendQadroThird} alt="qadro">
   </div>
</label>
<input readOnly type="radio" name="slider-2" id="s3-2">

about 4 years ago · Santiago Gelvez Report

0

Simply write for instead of htmlFor.

about 4 years ago · Santiago Gelvez 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!