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

164
Views
How to validate react select dropdown list without using hook

Can I validate my select dropdown without using react-hook, I have to ensure that the value in the select is never empty / null when user clicked onto the submit button.

handleChange = (option) => { this.setState({option:option.target.value})
<Select onChange={this.handleChange} value={this.state.option}>
<MenuItem>test1</MenuItem>
<MenuItem>test2</MenuItem>
</Select>

This is the current code for my react select, I would like to validate it so that the is never empty when clicking on submit button. As the code for my submit is just as below, along with basic buttons function etc..

OnClickSubmit(event)=>{event.preventDefault()}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can put a check on the OnClickSubmit method.

OnClickSubmit(event)=>{
   event.preventDefault()
   
   // check if value is not empty/null before invoking your fns
   if(!!this.state.option){
      // invoke your functions here
      ...
   }
   
}
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!