Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

289
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda