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

368
Views
(React.js) How to disable inputs until the previous input is enterred?

I have an input element returned by an Array of strings like the image below. How can I write the input component so that the subsequent inputs are disabled until the current input is entered by the user? Users can only start with the input from the top left then move to the right accordingly.

function() {

return (
<div>

  {strArr.map((item, index) => (
    <input />
  ))}
</div>
)}

Thanks for your help!

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  • First of all set state and call it like isActive
  • Second, give your input an identifier like id that can be equal to the current
  • So, by default, your state will be initialized with 0;
  • Set disabled property of your input dynamically, if isActive is not equal to the current state it gonna be disabled,
function() {
const [isActive, setIsActive] = React.useState(0);
const handleOnInputChange = (index)=>{
setIsActive(index+1)
}
return (
<div>

  {strArr.map((item, index) => (
    <input ket={index} id={index} disabled={isActive !== index} onChange={()=>handleOnInputChange(index)}/>
  ))}
</div>
)}
  • This gonna work if you have only to write a single character in your input
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!