- Introduction
- Understanding Forms
- Creating a Form
- Inserting Form Objects
- Modifying Text Fields and Text Areas
- Modifying Radio Buttons and Check Boxes
- Modifying Lists and Menus
- Modifying Buttons
- Inserting an Image Button
- Making Form Objects Dynamic
- Using Tables to Control Forms
- Validating Forms
- Creating and Editing a Jump Menu
- Viewing Example Code for Forms
Validating Forms
The Validate Form action checks the contents of specified text fields to ensure that the user has entered the correct type of data. You can attach this action to individual text fields using an onBlur event to validate the fields as the user is filling out the form, or attach it to the form with the onClick event to evaluate several text fields at once when the user clicks the Submit button. Attaching this action to a form prevents the form from being submitted to the server if any of the specified text fields contains invalid data. In addition, 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.
Validate HTML Form Data
- Open a form document, or create a new form document.
- Select the Submit button inside the form that you want to validate.
- Click the Window menu, and then click Behaviors to display the Behaviors panel.
- Click the Add Behavior button (the Plus (+) sign), and then click Validate Form
- Select the form input fields one at a time, and then validate the form using the following options:
- Required. Select to make the form object required.
- Anything. Accepts any input entered by the user.
- Number. Restricts input to numeric.
- Email address. Looks for an e-mail address with the @ sign.
- Number from. Enables you to enter a minimum and maximum range for numeric values.
- Click OK to add the validation information (in script) to the HTML form document.
- Click the Action button in the Behaviors panel, and then select one of the following options:
- OnClick. Select if you are validating multiple fields when the user submits the form.
- OnBlur. Select if you are validating individual fields.
- Click the File menu, point to Preview In Browser, and then check the current validation actions.