Ensuring Two Form Fields Have Identical Information
By Will Bontrager2005-03-11
The Form
Here is an example form that asks for two items of information:
<form
name="FormName"
method="POST"
action="/cgi-bin/script.cgi">
<input
type="text"
name="FieldA"
size="19" />
<input
type="text"
name="FieldB"
size="19" />
<input
type="submit"
onclick="return BothFieldsIdenticalCaseSensitive();"
value="Click Me" />
</form>
Note that the submit button field has an onclick attribute. The value in the attribute calls a JavaScript function. The function runs, then returns either the value "true" or the value "false."
If the "true" value is returned, the form is submitted. But if the "false" value is returned, the form submission is aborted.
The name of the JavaScript function in the above example is BothFieldsIdenticalCaseSensitive(). This name can be changed depending on which JavaScript function you wish to run when the submit button is clicked.
Tutorial Pages:
» Ensuring Two Form Fields Have Identical Information
» The Form
» The JavaScript
» Integration Considerations
» Form Fields with Un-Identical Information
Copyright 2004 Bontrager Connection, LLC
