• View
  • Source

Method

setCheckboxValidation("WidgetContainerID", 'option1:"value1", option2:"value2", ..')

Example

1 2 3 4 5 Please make a selection. Select at least two Only 3 selections allowed

Handler

<cffunction name="dspCheckboxValidation" access="public" returntype="void" output="false">
    <cfargument name="Event" type="coldbox.system.beans.requestContext">
    <cfset Event.setView("spryExample/checkboxValidation")>
</cffunction>    

View

<style>
    label {
        display:block;
    }
</style>
<!--- Put spry plugin in variable scope --->
<cfset spry = getPlugin('Spry',true)>

<h1>Method</h1>
setCheckboxValidation("WidgetContainerID", 'option1:"value1", option2:"value2", ..')
<h1>Example</h1>
<form id="form1" name="form1" method="post" action="">
    <!--- Checkbox group--->
    <cfset spry.setCheckboxValidation('sprycheckboxgroup1','minSelections:2,maxSelections:3,validateOn:["change","blur"]')>
    <span id="sprycheckboxgroup1">  
        <label for="checkbox1">Required, maxSelections, minSelections</label>
        <input type="checkbox" name="checkbox1" /> 1  
        <input type="checkbox" name="checkbox2" /> 2
        <input type="checkbox" name="checkbox3" /> 3
        <input type="checkbox" name="checkbox4" /> 4
        <input type="checkbox" name="checkbox5" /> 5
        <span class="checkboxRequiredMsg">Please make a selection.</span>        
        <span class="checkboxMinSelectionsMsg">Select at least two</span>        
        <span class="checkboxMaxSelectionsMsg">Only 3 selections allowed</span>        
    </span>
</form>