HTML and CSS Reference
In-Depth Information
EXPLANATION ( CONTINUED )
2
The onSubmit event handler is an attribute of the HTML <form> tag. It will catch
the form just before it is sent off to the server. When the user clicks the submit
button, the event handler readySubmit() will be invoked. If the event handler is
called by the onSubmit attribute of the <form> tag, an explicit return must be used
(see Figure 11.20).
3
The input type is a submit button. When the user clicks this button, the JavaScript
onSubmit event is triggered. (See line 2.)
Figure 11.20 Submitting a form and the onSubmit event handler.
The onReset Event Handler. The HTML reset button allows the user to clear the
form fields and set them back to their default values. JavaScript will let you set up an
onReset event handler to either accept or reject this action. This event handler can be
used to make sure that clearing an entire form is really what you want to do before it's
too late, especially if you've done a lot of typing and don't want to reenter all that data.
It is an attribute of the <form> tag.
EXAMPLE 11.12
<html>
<head><title>The onReset Event</title>
<script type="text/javascript">
1
function resetAll(){
2
if(confirm("Do you want to reset the form to its default "
+ " values? ")){
3
return true;
}
else{
4
return false;
}
}
</script>
</head>
Continues
 
Search WWH ::




Custom Search