onreset event
Examples
When the Reset Form execute JavaScript:
<Form onreset = "myFunction ()">
Enter name: <input type = "text">
<Input type = "reset">
</ Form>
Enter name: <input type = "text">
<Input type = "reset">
</ Form>
try it"
Definition and Usage
onreset event is triggered when the form is reset.
Browser Support
event | |||||
---|---|---|---|---|---|
onreset | Yes | Yes | Yes | Yes | Yes |
grammar
In HTML:
<Elementonreset = "myScript"> try
In JavaScript:
object .onreset = function () {myScript }; try
JavaScript, use the addEventListener () method:
object .addEventListener ( "reset", myScript ); try
Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.
Technical Details
Whether to support the bubble: | Yes |
---|---|
It can be canceled: | Yes |
Event Type: | Event |
Supported HTML tags: | <Form>, <keygen> |
More examples
Examples
Written form before resetting to display the contents of the text field:
var x = document.getElementById ( "myInput");
alert ( "before resetting, with text:" + x.value);
alert ( "before resetting, with text:" + x.value);
try it"
Examples
Use HTML DOM Form Object The reset () method to reset the form. When executed, onreset event is triggered, and a message will pop up.
// Reset id = "myForm" all form element values
function myResetFunction () {
. Document.getElementById ( "myForm") reset ();
}
// After the Reset pop message form
function myAlertFunction () {
alert ( "form has been reset ');
}
function myResetFunction () {
. Document.getElementById ( "myForm") reset ();
}
// After the Reset pop message form
function myAlertFunction () {
alert ( "form has been reset ');
}
try it"