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

125
Views
How can I disable a button only if specific Input is empty?

I've tried to find a way to disable a button only if specific Inputs fields are still empty. I mean that only few Inputs fields are required for the process, and some are only optional.

The course which I take show us how to disable the button until every input is valid, so I'm not sure what to do.

This is my code, I want the button to be disable only if date is empty.

<form className="place-form" onSubmit={placeSubmitHandler}>
    <Input
    id="date"
    element="input"
    type="date"
    label="Date"
    validators={[VALIDATOR_REQUIRE()]}
    errorText=""
    onInput={inputHandler}
  />

  <Input
    id="description"
    element="textarea"
    label="description"
    validators={[VALIDATOR_MINLENGTH(5)]}
    errorText=""
    onInput={inputHandler}
  />
      

  <Button type="submit" disabled={ formState.isValid  }>
     Sumbit
  </Button>
</form>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to put Not sign like ! before formState.isValid

<Button type="submit" disabled={ !formState.isValid  }>
     Sumbit
  </Button>

I have prepared a sample using react-hook-form. you can check this here:

WORKING DEMO

Edit #SO-material-onclick-edit

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!