Search This Blog

Wednesday 23 October 2013

Popular Aui:Validators - validating your form with Aui:Validations

Hereby i have Listed the Default-Form Validators provided by AUI ,alongwith a few examples showing their implementation in our Application:

DEFAULT AUI : FORM VALIDATORS :

DEFAULT: Liferay.Language.get(‘please-fix-this-field’),
acceptFiles: Liferay.Language.get(‘please-enter-a-file-with-a-valid-extension-x’),
alpha: Liferay.Language.get(‘please-enter-only-alpha-characters’),
alphanum: Liferay.Language.get(‘please-enter-only-alphanumeric-characters’),
date: Liferay.Language.get(‘please-enter-a-valid-date’),
digits: Liferay.Language.get(‘please-enter-only-digits’),
email: Liferay.Language.get(‘please-enter-a-valid-email-address’),
equalTo: Liferay.Language.get(‘please-enter-the-same-value-again’),
max: Liferay.Language.get(‘please-enter-a-value-less-than-or-equal-to-x’),
maxLength: Liferay.Language.get(‘please-enter-no-more-than-x-characters’),
min: Liferay.Language.get(‘please-enter-a-value-greater-than-or-equal-to-x’),
minLength: Liferay.Language.get(‘please-enter-at-list-x-characters’),
number: Liferay.Language.get(‘please-enter-a-valid-number’),
range: Liferay.Language.get(‘please-enter-a-value-between-x-and-x’),
rangeLength: Liferay.Language.get(‘please-enter-a-value-between-x-and-x-characters-long’),
required: Liferay.Language.get(‘this-field-is-required’),
url: Liferay.Language.get(‘please-enter-a-valid-url’)
---------------------------------------------------------------------------------------------------------------------

Please find the implementation examples of few of the Deafult Aui Validators listed above:

## alpha :
<aui:input name="firstName" label="first-name" id="firstName" maxLength="20" >
<aui:validator name="alpha" errorMessage="please-enter-only-alpha-characters" />
</aui:input>

## digits && rangeLength :

<aui:input name="primaryMobileNo" label="primary-mobile-no"
id="primaryMobileNo" maxLength="15">
      <aui:validator name="digits" errorMessage="please-enter-valid-mobile-number" />
     <aui:validator name="rangeLength"
errorMessage="please-enter-valid-mobile-number">[8,15]</aui:validator>
</aui:input>

## email :
<aui:input name="primaryEmail" label="primary-email" id="primaryEmail">
<aui:validator name="email" errorMessage="please-enter-valid-email" />
</aui:input>

## alphanum :
<aui:input name="crmNumber" label="crm-no" id="customerCRMNo">
<aui:validator name="alphanum"
errorMessage="please-enter-valid-customer-CRMNo" />
</aui:input>

## minLength :
 <aui:validator name="minLength" errorMessage="Phone number format as (xxx) xxx-xxxx" >10</aui:validator>


## maxLength : 
<aui:validator name="maxLength" errorMessage="Phone number format as (xxx) xxx-xxxx">10</aui:validator>



Note: AUI doesn't provide as such any default Validators for Dropdowns , in such a case you need to implement you custom form validations for dropdowns,etc  using AUI or jQuery,etc
reference:  

No comments:

Post a Comment