beautypg.com

Apply the validate form behavior – Adobe Dreamweaver CC 2015 User Manual

Page 431

background image

424

Javascript

Last updated 6/3/2015

There is also a Swap Image Restore behavior, which restores the last set of swapped images to their previous source files.
This behavior is automatically added whenever you attach the Swap Image behavior to an object; if you leave the
Restore option selected while attaching Swap Image, you should never need to select the Swap Image Restore behavior
manually.

1

Select Insert > Image or click the Image button on the Insert panel to insert an image.

2

In the Property inspector, enter a name for the image in the leftmost text box.

It isn’t mandatory to name images; they’re named automatically when you attach the behavior to an object. However,
it is easier to distinguish images in the Swap Image dialog box if you name all the images beforehand.

3

Repeat steps 1 and 2 to insert additional images.

4

Select an object (generally the image you’re going to swap) and choose Swap Image from the Add Behavior menu of
the Behaviors panel.

5

From the Images list, select the image whose source you want to change.

6

Click Browse to select the new image file, or enter the path and filename of the new image in the Set Source To box.

7

Repeat steps 5 and 6 for any additional images you want to change. Use the same Swap Image action for all the
images you want to change at once; otherwise, the corresponding Swap Image Restore action won’t restore all of
them.

8

Select the Preload Images option to cache the new images when the page is loaded.

This prevents downloading delays when it is time for the images to appear.

9

Click OK and verify that the default event is correct.

Apply the Validate Form behavior

The Validate Form behavior checks the contents of specified text fields to ensure that the user has entered the correct
type of data. Attach this behavior to individual text fields with the onBlur event to validate the fields as the user is filling
out the form, or attach it to the form with the onSubmit event to evaluate several text fields at once when the user clicks
the Submit button. Attaching this behavior to a form prevents the submission of forms with invalid data.

1

Select Insert > Form or click the Form button in the Insert panel to insert a form.

2

Select Insert > Form > Text Field or click the Text Field button in the Insert panel to insert a text field.

Repeat this step to insert additional text fields.

3

Choose a validation method:

• To validate individual fields as the user fills out the form, select a text field and select Window > Behaviors.

• To validate multiple fields when the user submits the form, click the

tag in the tag selector at the lower-

left corner of the Document window and choose Window > Behaviors.

4

Select Validate Form from the Add Behavior menu.

5

Do one of the following:

• If you are validating individual fields, select the same field that you selected in the Document window from the

Fields list.

• If you are validating multiple fields, select a text field from the Fields list.

6

Select the Required option if the field must contain some data.

7

Select one of the following Accept options:

Use Anything

Checks that a required field contains data; the data can be of any type.