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.

...<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

var sprytextarea1 = new <strong>Spry</strong>.Widget.ValidationTextarea("sprytextarea1");<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 enter a description<br />

<br />

The .textareaRequiredMsg rule is located in the <strong>Spry</strong>ValidationTextarea.css file, and is set to display:none by<br />

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

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

appearance of the error message.<br />

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

.textareaRequiredMsg,<br />

.textareaMinCharsMsg,<br />

.textareaMaxCharsMsg,<br />

.textareaValidMsg {<br />

display:none;<br />

}<br />

.textareaRequiredState .textareaRequiredMsg,<br />

.textareaMinCharsState .textareaMinCharsMsg,<br />

.textareaMaxCharsState .textareaMaxCharsMsg {<br />

display: inline;<br />

color: #CC3333;<br />

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

}<br />

By default, there is no state class 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 .textareaRequiredMsg class applied to it. (The<br />

propertyandvaluepairforthisruleisdisplay:none, so the message remains hidden.) If the user fails to enter text<br />

in a required text area, however, <strong>Spry</strong> applies the appropriate class to the widget container, as follows:<br />

<br />

<br />

Please enter a description<br />

<br />

SPRY<br />

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

70

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

Saved successfully!

Ooh no, something went wrong!