Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reset input react

const App = () => {
  const [message, setMessage] = useState('');
  return (
    <div>
      <input
        type="text"
        value={message}
		onChange={(event) => {
          setMessage(event.target.value);
        }}/>

      <button 
		onClick={() => {
          alert('check')
          // clear input value
          setMessage('');
        }}>
          Clear field
      </button>
    </div>
  );
};
Comment

reset form input react

cancelCourse = () => { 
  document.getElementById("create-course-form").reset();
}

render() {
  return (
    <form id="create-course-form">
      <input />
      <input />
      ...
      <input />
    </form>
  );
}
Comment

reset form in react

<!-- you just need a button type of reset -->
<form>
  <div>
   <label for="name">Name</label>
   <input type="text" id="name" placeholder="name" />
  </div>
  <div>
   <label for="password">Password</label>
   <input type="password" id="password" placeholder="password" />
  </div>
  <button type="reset">Reset</button> 
  <button>Submit</button>
</form>
Comment

PREVIOUS NEXT
Code Example
Javascript :: get query params react 
Javascript :: jquery get all input name and values and submit 
Javascript :: fetch js 
Javascript :: javascript return object property from array 
Javascript :: add eslint dependencies for cypress 
Javascript :: npx electron command 
Javascript :: https error response with status 200 angular 
Javascript :: getfullyear javascript 
Javascript :: remove repetition 2d array javascript 
Javascript :: get position of element relative to document 
Javascript :: how to run an existing react project 
Javascript :: fahrenheit to celsius in javascript 
Javascript :: package.json in node js 
Javascript :: remove element from array by name javascript 
Javascript :: how to change mui ripple color 
Javascript :: javascript how to take off a decimal 
Javascript :: while and do while loop in javascript 
Javascript :: get current url react router 
Javascript :: get current html file name javascript 
Javascript :: primitive data types in javascript 
Javascript :: open folder node js 
Javascript :: call json api javascript 
Javascript :: how to remove property of object in javascript without delete 
Javascript :: how to get a random statement from an array in javascript 
Javascript :: jquery code to make click function 
Javascript :: string to array angular 
Javascript :: click select option to update div jquery 
Javascript :: get minutes and seconds of long seconds 
Javascript :: add image to ag-grid with react 
Javascript :: javascript object instead of switch 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =