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

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

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 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