Dreamweaver

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 and ASP.NET forms in Dreamweaver that validate the contents of specified fields. For ASP.NET forms, you can insert ASP.NET validation controls in Code view. For more information, consult the ColdFusion and ASP.NET 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 person’s age accepts only numbers.

    Note: The Validate Form behavior is available only if a text field has been inserted into the document.