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

134
Visualizações
Reseting form value upon submission

I need help with clearing out a form input when the form has been submitted. When I submit the form, the information that I put in stays there, is there a way I can clear this out? Thanks so much for taking time out of your day to help me. Here is the code

const [data, setData] = useState(null);
  function getData(e) {
    setData(e.target.value);
  }

  function handleSubmit(e) {
    e.preventDefault();
  }

  //function that grabs user input and insert into function
  const inputValue = () => {
    var userSet = data.split("");
    getRandom(userSet);
  };

  return (
    <div>
      <h1>LIA</h1>
      <Chalkboard />

      <h1>Letter set: {data}</h1>
      <form onSubmit={handleSubmit}>
        <input onChange={getData} className="inputField" type="text" placeholder="Enter letters" />
        <button onClick={inputValue} value="Start">
          Start
        </button>
      </form>
  
    </div>
  );
};

export default IntervalFunction;

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First of all, you should have a value property on your input field. This property in this case should contain the data variable. So, this way, on the handleSubmit method, you can call setData(null) or setData("") so as to reset the content of the input field.

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