Form Validation In Liferay -- Client Side validation

In Liferay we can do client side validation very easily.

 We use <aui:validator>  tag to do validations.

It allows "name" and "errormessage" attributes

Names it allows are:

  1. alpha
  2. alphanum
  3. date
  4. digits
  5. email
  6. equalTo
  7. number
  8. acceptFiles
  9. min
  10. minLength
  11. max
  12. maxLength
  13. range
  14. rangeLength
  15. required
  16. url
  17. custom
Here custom is use to give custom validations ,
Below Exampleis the custom validation for email validation .In Liferay for email sometimes its is not working. So i am writing the custom validation. 

Just Copy & paste the code and try it will perfectly works

<aui:validator name="custom" errorMessage="Please enter valid email address">

      function (val, fieldNode, ruleValue) {
          var result = false;
       var emailRegexStr = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
        var isvalid = emailRegexStr.test(val);
if (isvalid) {
 result = true;
}
 return result;
}
         </aui:validator>

Comments

Post a Comment

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Opening portlet in popup