Event handler onreset
(Bubbles: No, Cancelable: Yes) terjadi ketika tombol Reset ditekan di dalam elemen FORM, dan terjadinya sebelum data-data di dalam elemen FORM masing-masing dikembalikan ke nilai awalnya.
Berikut contoh meregister event handler onreset
via 'inline model':
<P>Log-In:</P>
<FORM ONRESET="alert('Anda mereset data')">
Nama:<INPUT TYPE="text">
Password:<INPUT TYPE="password">
<INPUT TYPE="reset" VALUE="Reset">
</FORM>
Berikut contoh meregister event handler onreset
via 'traditional model':
<P>Log-In:</P>
<FORM ID="formID">
Nama:<INPUT TYPE="text">
Password:<INPUT TYPE="password">
<INPUT TYPE="reset" VALUE="Reset">
</FORM>
<SCRIPT TYPE="text/javascript">
function HandleEvent()
{
alert('Anda mereset data');
}
document.getElementById("formID").onreset=HandleEvent;
</SCRIPT>
Berikut contoh meregister event handler onreset
via DOM:
<P>Log-In:</P>
<FORM ID="formID">
Nama:<INPUT TYPE="text">
Password:<INPUT TYPE="password">
<INPUT TYPE="reset" VALUE="Reset">
</FORM>
<SCRIPT TYPE="text/javascript">
function HandleEvent()
{
alert('Anda mereset data');
}
var formElem=document.getElementById("formID");
formElem.addEventListener("reset", HandleEvent, false);
</SCRIPT>