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.

Specify when validation occurs<br />

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

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

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

makes selections.<br />

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

<br />

var sprycheckbox1 = new <strong>Spry</strong>.Widget.ValidationCheckbox("sprycheckbox1",<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 />

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

By default, a Validation Checkbox widget is set to required. If you insert a number of checkboxes on your page,<br />

however, you can specify a minimum and maximum selection range. For example, if you have six checkboxes within<br />

the span tagforasingleValidationCheckboxwidget,andyouwanttomakesurethattheuserselectsatleastthree<br />

checkboxes, you can set such a requirement for the entire widget.<br />

❖ To specify a minimum or maximum number of selections, add the minSelections property or maxSelections<br />

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

<br />

var checkboxwidget1 = new<br />

<strong>Spry</strong>.Widget.ValidationCheckbox("checkboxwidget1",{minSelections:value,<br />

maxSelections:value});<br />

<br />

Change required status of checkboxes<br />

By default, Validation Checkbox widgets require the user to make at least one selection before submitting the form.<br />

You can, however, make selections optional for the user.<br />

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

false, as follows:<br />

<br />

var checkboxwidget1 = new <strong>Spry</strong>.Widget.ValidationCheckbox("checkboxwidget1",<br />

{isRequired:false});<br />

<br />

Customize the Validation Checkbox widget<br />

The <strong>Spry</strong>ValidationCheckbox.css file provides the default styling for the Validation Checkbox widget. You can<br />

customize the widget by changing the appropriate CSS rule. The CSS rules in the <strong>Spry</strong>ValidationCheckbox.css file<br />

use the same class names as the related elements in the widget’s HTML code, so it’s easy for you to know which CSS<br />

rules correspond to the widget and its error states.<br />

The <strong>Spry</strong>ValidationCheckbox.css file should already be included in your website before you start customizing. For<br />

more information, see “Prepare your files” on page 3.<br />

SPRY<br />

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

89

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

Saved successfully!

Ooh no, something went wrong!