The ace:clientValidateLength component validates the input of the enclosing component by allowing only the text content with its length within the defined limits to be submitted. In the case of ace:checkboxButtons component the length constraints are applied to the number of checked checkboxes.
The ace:clientValidateLength component can be used to validate the following:
- A minimum length (minimum attribute)
- A maximum length (maximum attribute)
- A length range (minimum and maximum attributes)
|See the ICEfaces Showcase Live Demo of this component, complete with source code.|
<html ... xmlns:ace="http://www.icefaces.org/icefaces/components">
// Validates that the entered text value has a minimum length of 5 characters.
<ace:textEntry id="password" label="Password " labelPosition="left"
<ace:clientValidateLength minimum="5" />
// Validates that between 2 and 3 checkboxes have been selected/checked.
header="Choose 2 or 3 letters"
<f:selectItem itemLabel="A" itemValue="One" />
<f:selectItem itemLabel="B" itemValue="Two" />
<f:selectItem itemLabel="C" itemValue="Three" />
<f:selectItem itemLabel="D" itemValue="Four" />
<ace:clientValidateLength minimum="2" maximum="3"/>
This section covers attributes involved in the typical use-cases for this component. For reference, the complete taglib documentation for this component is available here.
minimum required length of the input.
maximum allowed length of the input.
- Client validation occurs initially when the component value is attempted to be submitted to the server, either via an ace:ajax partial-submit or a full form submit. If the client validation fails the submit to the server is aborted and the appropriate error message is displayed in an associated ace:message, ace:messages, or ace:growlMessages component (without requiring a server-roundtrip). Thus, a form submit with multiple components is processed atomically and will be completely aborted if any of the components within it fail client validation.
- Before submitting an entered component value the first time (either via full form submit, or an ace:ajax partial-submit), the user can tab through components in the form without triggering annoying validation messages - they won't get bugged before having the chance to actually enter a correct value.
- However, once a component is marked invalid by a previous validation failure, it is eagerly validated: As soon as the user has entered the necessary value, the error message is removed, without requiring a form submit.
- Client validation supports the "immediate='true'" attribute on ace:pushButton and ace:linkButton. When "immediate='true'" the button submit will occur regardless of whether one or more components in the form are failing client validation.
No direct event listener is associated with this component.
Client Behavior Events
No direct client behavior is associated with this component.
Keyboard and ARIA Support
- Client Validation is not supported with the ace:maskedEntry component.