The onreset and onsubmit Event Handlers : Form Reset « Form Control « JavaScript DHTML

The onreset and onsubmit Event Handlers



<title>Submit and Reset Confirmation</title> 
<script type="text/javascript"> 
function allowReset() { 
    return window.confirm("Go ahead and clear the form?"); 
function allowSend() { 
    return window.confirm("Go ahead and mail this info?"); 


<form method="POST" enctype="text/plain" action="" onreset="return allowReset()" onsubmit="return allowSend()"> 

Enter your first name:
<input type="text" name="firstName" id="firstName"/> 
Enter your last name:
<input type="text" name="lastName" id="lastName"/>
Enter your address:
<input type="text" name="address" id="address"/>
Enter your city:
<input type="text" name="city" id="city" />
<input type="radio" name="gender" id="gender1" checked="checked" />
<input type="radio" name="gender" id="gender2" />Female
<input type="checkbox" name="retired" id="retired" />I am retired
<input type="reset" /> 
<input type="submit" />


Related examples in the same category

1.Reset the fields in a form
2.form.reset() and form.submit() Methods