04.02.2013 Views

Spry User Guide - Support - Adobe

Spry User Guide - Support - Adobe

Spry User Guide - Support - Adobe

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

"custom", {pattern:"00 0000 AX"});<br />

<br />

The following table shows a full list of values used for custom patterns.<br />

Value Description<br />

"0" Whole numbers between 0 and 9<br />

"A" Uppercase alphabetic characters<br />

"a" Lowercase alphabetic characters<br />

"B"; "b" Case-insensitive alphabetic characters<br />

"X" Uppercase alpha-numeric characters<br />

"x" Lowercase alpha-numeric characters<br />

"Y"; "y" Case-insensitive alpha-numeric characters<br />

"?" Any character<br />

The "A", "a", "X", and "x" custom pattern characters are case sensitive. In situations that use these characters, <strong>Spry</strong><br />

converts the characters to the correct case, even if the user enters the wrong case.<br />

Specify when validation occurs<br />

By default, the Validation Text Field widget validates when the user clicks the submit button. You can, however, set<br />

two other options: blur or change.ThevalidateOn:["blur"] parameter causes the widget to validate whenever<br />

the user clicks outside the text field. The validateOn:["change"] parameter causes the widget to validate as the<br />

user changes text inside the text field.<br />

❖ To specify when validation occurs, add a validateOn parameter to the constructor as follows:<br />

<br />

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

{validateOn:["blur"]});<br />

<br />

As a convenience, you can discard the brackets if your validateOn parameter contains a single value (for example,<br />

validateOn: "blur"). If the parameter contains both values, however (validateOn:["blur", "change"]),<br />

include brackets in the syntax.<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 />

Specify a minimum and maximum number of characters<br />

This option is only available for the "none", "integer", "email", and "url" validation types.<br />

The minChars option does not enforce a minimum number of characters if the text field is not required.<br />

❖ To specify a minimum or maximum number of characters, add the minChars property or maxChars property (or<br />

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

SPRY<br />

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

60

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

Saved successfully!

Ooh no, something went wrong!