04.02.2013 Views

Spry User Guide - Support - Adobe

Spry User Guide - Support - Adobe

Spry User Guide - Support - Adobe

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Make sure that the file path to the <strong>Spry</strong>ValidationTextField.js file is correct. This path varies depending on where<br />

you’ve placed the file in your web site.<br />

4 Link the <strong>Spry</strong>ValidationTextField.css file to your web page by inserting the following link tag in the page’s head tag:<br />

<br />

Make sure that the file path to the <strong>Spry</strong>ValidationTextField.css file is correct. This path varies depending on where<br />

you’ve placed the file in your web site.<br />

5 Add a text field the page and give it a name and a unique ID:<br />

<br />

6 To add a container around the text field, insert span tags around the input tags, and assign a unique ID to the<br />

widget, as follows:<br />

<br />

<br />

<br />

7 Initialize the text field object by inserting the following script block after the HTML code for the widget:<br />

<br />

var sprytextfield1 = new <strong>Spry</strong>.Widget.ValidationTextField("sprytextfield1");<br />

<br />

The new JavaScript operator initializes the Text Field widget object, and transforms the span tag content with the ID<br />

of sprytextfield1 from static HTML code into an interactive text field object. The <strong>Spry</strong>.Widget.Validation-<br />

TextField method is a constructor in the <strong>Spry</strong> framework that creates text field objects. The information necessary<br />

to initialize the object is contained in the <strong>Spry</strong>ValidationTextField.js JavaScript library that you linked to at the<br />

beginning of this procedure.<br />

Make sure that the ID of the text field’s container span tag matches the ID parameter you specified in the<br />

<strong>Spry</strong>.Widgets.ValidationTextField method. Make sure that the JavaScript call comes after the HTML code for<br />

the widget.<br />

8 Save the page.<br />

The complete code looks as follows:<br />

<br />

...<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

var sprytextfield1 = new <strong>Spry</strong>.Widget.ValidationTextField("sprytextfield1");<br />

<br />

<br />

SPRY<br />

<strong>User</strong> <strong>Guide</strong><br />

48

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!