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.

...<br />

<br />

<br />

<br />

<br />

<br />

<br />

--Please select an item--<br />

Item 1<br />

Item 2<br />

Invalid Item<br />

Item 3<br />

Empty Item<br />

<br />

<br />

<br />

var spryselect1 = new <strong>Spry</strong>.Widget.ValidationSelect("spryselect1");<br />

<br />

<br />

Display error messages<br />

❖ Create a span tag (or any other type of tag) to display the error message, and assign the appropriate class to it, as<br />

follows:<br />

<br />

<br />

--Please select an item--<br />

Item 1<br />

. . .<br />

<br />

Please select an item.<br />

<br />

The selectRequiredMsg ruleislocatedinthe<strong>Spry</strong>ValidationSelect.cssfile,andissettodisplay:none by default.<br />

When the widget enters a different state through user interaction, <strong>Spry</strong> applies the appropriate class—the state<br />

class—to the container of the widget. This action affects the error-message class, and by extension, the appearance<br />

of the error message.<br />

For example, the following shows a portion of the CSS rule from the <strong>Spry</strong>ValidationSelect.css file:<br />

.selectRequiredMsg, .selectInvalidMsg {<br />

display: none;<br />

}<br />

.selectRequiredState .selectRequiredMsg,<br />

.selectInvalidState .selectInvalidMsg {<br />

display: inline;<br />

color: #CC3333;<br />

border: 1px solid #CC3333;<br />

}<br />

By default, no state class is applied to the widget container, so that when the page loads in a browser, the error<br />

message text in the preceding HTML code example only has the .selectRequiredMsg class applied to it. (The<br />

property and value pair for this rule is display:none, so the message remains hidden.) If the user fails to make a<br />

selection, however, <strong>Spry</strong> applies the appropriate class to the widget container, as follows:<br />

SPRY<br />

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

80

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

Saved successfully!

Ooh no, something went wrong!