A copy of the JavaScript functions in the head element:
// sample-1-onsubmit.js
// This sample shows processing onsubmit of a form
// on load of the body
function loaded()
{
// reset the input text data
current_input_text_object = document.getElementById("control1");
current_input_text_object.value = null;
// reset radio button
current_radio_button_array = document.getElementsByName("age");
var checked = false;
for ( var i = 0; i < current_radio_button_array.length ; i++ )
{
current_radio_button_array[i].checked = false;
}
// reset select list
var pet_selection_list = document.getElementById("petSelectionElement");
pet_selection_list.selectedIndex = -1;
}
// form onsubmit handler
function onsubmit_function(current_form)
{
var rc = true;
// test for empty input text area
current_input_text_object = document.getElementById("control1");
if ( current_input_text_object.value == null || current_input_text_object.value == "" )
{
alert("Pet name must be entered");
rc=false;
}
// test for no radio button checked
current_radio_button_array = document.getElementsByName("age");
var checked = false;
for ( var i = 0; i < current_radio_button_array.length ; i++ )
{
if ( current_radio_button_array[i].checked )
checked = true;
}
if ( ! checked )
{
alert("Pet age must be selected");
rc=false;
}
// test for no option selected
var pet_selection_list_element = document.getElementById("petSelectionElement");
if (pet_selection_list_element.selectedIndex < 0 )
{
alert("Type of pet must be selected");
rc=false;
}
return rc;
}