Operation Manual

Table Of Contents
646
Dynamic sites, pages and web forms
Last updated 11/30/2015
Validate HTML form data
Dreamweaver can add JavaScript code that checks the contents of specified text fields to ensure that the user has entered
the correct type of data.
You can use Spry form widgets to build your forms and validate the contents of specified form elements. For more
information, consult the Spry topics listed below.
You can also build ColdFusion forms in Dreamweaver that validate the contents of specified fields. For more
information, consult the ColdFusion chapter listed below.
1 Create an HTML form that includes at least one text field and one Submit button.
Make sure every text field that you want to validate has a unique name.
2 Select the Submit button.
3 In the Behaviors panel (Window > Behaviors), click the Plus (+) button and select the Validate Form behavior from
the list.
4 Set the validation rules for each text field, and click OK.
For example, you might specify that a text field for a persons age accepts only numbers.
Note: The Validate Form behavior is available only if a text field has been inserted into the document.
Attach JavaScript behaviors to HTML form objects
You can attach JavaScript behaviors stored in Dreamweaver to HTML form objects such as buttons.
1 Select the HTML form object.
2 In the Behaviors panel (Window > Behaviors), click the Plus (+) button, and select a behavior from the list.
Attach custom scripts to HTML form buttons
Some forms use JavaScript or VBScript to perform form processing or some other action on the client as opposed to
sending the form data to the server for processing. You can use Dreamweaver to configure a form button to run a
specific client-side script when the user clicks the button.
1 Select a Submit button in a form.
2 In the Behaviors panel (Window > Behaviors), click the Plus (+) button, and select Call JavaScript from the list.
3 In the Call JavaScript box, enter the name of the JavaScript function to run when the user clicks the button, and click
OK.
For example, you can enter the name of a function that doesn’t exist yet, such as processMyForm().
4 If your JavaScript function doesnt exist in the head section of the document yet, add it now.
For example, you could define the following JavaScript function in the head section of the document to display a
message when the user clicks the Submit button:
function processMyForm(){
alert('Thanks for your order!');
}