Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reset event listener javascript



const form = document.getElementById('form');
const log = document.getElementById('log');
form.addEventListener('reset', logReset); // reset form input values
function logReset(event) {
  log.textContent = `Form reset! Time stamp: ${event.timeStamp}`;
}
Comment

event reset javascript

<form onreset="window.alert('All the information you entered will be cleared and the form will now be reset');">
Name: <input type="text" value=""/><br><br>
Email: <input type="text" value=""/><br><br>
Phone: <input type="text" value=""><br><br>
<input type="Reset" value="Reset"/> </form>

The onreset event handler is attached to the <form> tag,
not the actual reset button, but the tag of the form itself. 
For the onreset event handler to work, the form button must be of type Reset. 
Since the event handler handles resets of forms, 
the button of the form must be of type reset. 
This reset button click is what triggers the onreset event handler.
Comment

PREVIOUS NEXT
Code Example
Javascript :: create variable javascript 
Javascript :: uppercase 
Javascript :: js for i in html collection 
Javascript :: amcharts 
Javascript :: cypress set date to specific date 
Javascript :: javascript number to string 
Javascript :: npm: Create react chrome extension 
Javascript :: regex for international phone number 
Javascript :: decode jwt token without library 
Javascript :: js extract properties from object 
Javascript :: date match mongodb 
Javascript :: object loop 
Javascript :: pwa clear cache 
Javascript :: How to get random no. without math.random() function 
Javascript :: js slice 
Javascript :: how to add changes every time you route navigate to page in angular 
Javascript :: react native geocoding 
Javascript :: react native cli sdk.dir 
Javascript :: reset reactive state vue 3 
Javascript :: node get path of current file 
Javascript :: Passing objects as Props in react 
Javascript :: devtool google 
Javascript :: javascript addeventlistener pass parameters 
Javascript :: angular js get selectedGroup for optGroup 
Javascript :: react redux form validation 
Javascript :: react moment calendar times 
Javascript :: prevent history back javascript 
Javascript :: node js classes 
Javascript :: do i need to know javascript to learn three.js 
Javascript :: jquery find element 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =