aui validator equalsTo is only for password?

988 views Asked by At

I want to make a confirm emailaddress like confirm password in liferay form the confirm password uses aui validator equals to, to campare both fields of password, my doubt is: Can I use this aui:validator to validate a non-password field?

2

There are 2 answers

0
Learner On BEST ANSWER

we can use aui validator to validate any thing which needs to be validated. no connection with password field.

<aui:input name="lastName" value=" " showRequiredLabel="" label="Last Name"> <aui:validator name="required"/> </aui:input>

You can also include your custom validations like :

`  <aui:input name="firstName" value=""  showRequiredLabel="" label="First Name">
        <aui:validator name="required"/> 
        <aui:validator name="custom" errorMessage="Enter valid First name">
            function validateName(name) 
                { 
                    if(name.trim() == '')
                    {
                        return true;
                    }
                    var re = /^([a-zA-Z ']{1,75})$/;
                    return re.test(name);
                }
        </aui:validator>
    </aui:input>
0
TheVillageIdiot On

Don't think this will make any difference. Compare (equalTo) validator will only compare values of two given controls. Like:

<aui:input name="email" value='' label="Email">
     <aui:validator name="email" />
</aui:input>

<aui:input name="email2" value='' label="Confirm Email">
    <aui:validator name="equalTo">'#<portlet:namespace />email'</aui:validator>
</aui:input>