Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda