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

148
Views
React-hook-form reset submit button disabled state after submit?

I have a form build with react-hook-form v7 and there is one thing that I can not make it work. The submit button is disabled until some field in the form gets a value, then when I click on the submit button it gets disabled to avoid submitting the form twice by mistake. With the form submitted and the button disabled if I make a change in some field the submit button remains disabled and that is what I can't make it work, I want the button gets enabled if I make changes in the form.

This is the code for the form:

const {
        control,
        handleSubmit, reset,
        formState: { errors, isDirty, isSubmitted, },
    } = useForm<ISearchListFormFields>({
        defaultValues: {
            chiefCategory: null,
        },
        mode: 'onChange'
    });
    
 <form onSubmit={handleSubmit(onSubmit)}>
    <div>
      <Label className='select-label'>Chefskategori</Label>
          <Controller
              control={control}
              name='chiefCategory'
              render={({ field: { onChange, value, ref } }) => (
                  <Select
                    inputRef={ref}
                    className='react-select-container authoritySelect'
                    classNamePrefix='react-select'
                    placeholder='Välj'
                    options={categoryList}
                    value={
                      categoryList.find((c) => c.value === value)
                        ? categoryList.find((c) => c.value === value)
                        : null
                    }
                    onChange={(val) => {onChange(val.value);}}
                  />
              )}
           />
    </div>
    <div>
      <RKPrimaryButton
        text='Search'
        type='submit'
        disabled={!isDirty || isSubmitted}
      />
    </div>
 </form>

Thanks for any help!

about 4 years ago · Juan Pablo Isaza
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!