Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!