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.

var textfieldwidget1 = new <strong>Spry</strong>.Widget.ValidationTextField("textfieldwidget1",<br />

"validation_type", {minChars:value, maxChars:value});<br />

<br />

Note: If a validation type is not required, you can set the validation type to "none".See“Specifyavalidationtypeand<br />

format” on page 50.<br />

Specify minimum and maximum values<br />

This option is only available for the "integer", "date", "time", "currency", and "real" validation types.<br />

❖ To specify minimum or maximum values in the text field, add the minValue property or maxValue property (or<br />

both) and a value to the constructor, as follows:<br />

<br />

var textfieldwidget1 = new <strong>Spry</strong>.Widget.ValidationTextField("textfieldwidget1",<br />

"validation_type", {minValue:value, maxValue:value});<br />

<br />

Change required status of a text field<br />

By default, Validation Text Field widgets require user input when published on a web page. You can, however, make<br />

the completion of text fields optional for the user.<br />

❖ To change the required status of a text field, add the isRequired property to the constructor and set its value to<br />

false, as follows:<br />

<br />

var textfieldwidget1 = new <strong>Spry</strong>.Widget.ValidationTextField("textfieldwidget1", "none",<br />

{isRequired:false});<br />

<br />

Note: In the preceding example, the second parameter is set to "none", but it could easily be set to any of the available<br />

validation types (for example, "phone" or "credit_card"). See “Specify a validation type and format” on page 50.<br />

Create a hint for a text field<br />

Because there are so many different kinds of formats for text fields, it is helpful to give your users a hint as to what<br />

format they need to enter. For example, a text field set with the Phone Number validation type accepts phone<br />

numbers in the form (000) 000-0000 by default. You can enter these sample numbers as a hint so that the text field<br />

displays the correct format when the user loads the page in a browser.<br />

This option doesn't depend on the validation type, so you can always specify it. (Specify "none" as your validation<br />

type, if no other validation type is required.) When the user clicks inside the text field, the hint disappears; when the<br />

user clicks outside the text field, <strong>Spry</strong> restores the hint to the textfield if the field contains no value.<br />

❖ To create a hint for a text field, add the hint property to the third parameter of the constructor and the text of<br />

your hint as the value, as follows:<br />

<br />

var textfieldwidget1 = new <strong>Spry</strong>.Widget.ValidationTextField("textfieldwidget1",<br />

"validation_type", {hint:"some hint text here"});<br />

<br />

SPRY<br />

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

61

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

Saved successfully!

Ooh no, something went wrong!