Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Ensuring Two Form Fields Have Identical Information

By Will Bontrager
2005-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


 | Bookmark
Related Tutorials:
» JavaScript Debugging Techniques with Firebug
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Essential Javascript -- A Javascript Tutorial
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function