A copy of the JavaScript functions in the head element:
// sample-6-form-functions.js
// This sample corresponds to "Accessing forms with JavaScript 1) in my lecture notes
// This sample uses getElementById() to find the form
// Then it finds the result element as a child of the form
// reset validation function
// returns false if the reset element value is an empty string
// otherwise returns true
function validate()
{
var rc = false;
var form_element = document.getElementById("only-form");
var result_element = form_element.result;
// The value of the result is always set to "" either
// by the body onload call to the loaded() function, or
// by the input onchange call to the changeInput() function
// unless the changeInput has set it to a numeric value.
// check the value attriabute of the result element
if(result_element.value != "")
{
rc = true;
}
return rc;
}
// ----------------------------------------------------------------------------
// the functions loaded() and changeInput() are the same as in previous samples.
// see the previous examples for the code for these two functions.