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

290
Vistas
react input field show the input althogh the user input is not legal, the value suppose to be numeric and the state doesnt change until it is numeric

my input field is showing letters it recieved as inputs althogh its state is not updated due to the test i have at the onchange event. for example: input field="dldld" and the state will be "".

my onchange function:

const handleChangeAdRentContent = (e) => {
    const re = /^[0-9\b]+$/;
    if (e.target.min) {
      if (e.target.value === "" || re.test(e.target.value)) {
        const name = e.target.name;
        const value = e.target.value;
        setInputAdConentRent({ ...inputAdConentRent, [name]: value });
      
        return;
      } else {
        return;
      }
    }
  };

this is the input field:

 <label
              key={masters[index].name + masters[index].adID}
              className={notdisplayRent}
            >
              <span>{masters[index].free_text}</span>
              <input
                type="text"
                name={masters[index].name}
                min={masters[index].min_value}
                max={masters[index].max_value}
                id={masters[index].name}
                required={masters[index].required}
                value={inputAdConentRent.name}
                onChange={handleChangeAdRentContent}
              />
            </label>

this is the input it consitst of an object of many inputs controlled by [key,value]

const [inputAdConentRent, setInputAdConentRent] = useState({});

thank you very much

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