Home > Articles > Web Development > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

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

  • green_1.jpg Open a form document, or create a new form document.
  • green_2.jpg Select the Submit button inside the form that you want to validate.
  • green_3.jpg Click the Window menu, and then click Behaviors to display the Behaviors panel.
  • green_4.jpg Click the Add Behavior button (the Plus (+) sign), and then click Validate Form
  • green_5.jpg 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.
  • green_6.jpg Click OK to add the validation information (in script) to the HTML form document.
  • green_7.jpg 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.
    f14dwcs21.jpg
  • green_8.jpg Click the File menu, point to Preview In Browser, and then check the current validation actions.
  • + Share This
  • 🔖 Save To Your Account