Search code examples
spring-mvcliferayliferay-auialloy-ui

partial AUI validation


Am having a form with two different sections, one is filter section and another one is details section. am using spring MVC with AUI components in liferay6.2. The filter section has few fields in which some of them is mandatory. am using aui validator with "required" to validate those fields. upon clicking list, the filter section need to be validated and once the validation passes action would be triggered(Action request) to populate the details section. The details section is editable and there are few mandatory fields which needs to be validated during save. AUI validators are binded for the fields in the details section also.

The problem is how to distinguish the validation. am having the single form and a single model. Upon of clicking list, the aui validator started validating the details section also. Is there any solution ? is it possible to have two forms with two model ? is there any option in AUI validator to achieve partial validation like while click on list aui need to validate only the filter section and while clicking on save, aui need to validate only the details section ?


Solution

  • The required validator can be passed a JS function to conditionally make the field required. The function needs to return either true or false.

    Using jsp taglibs...

    <aui:validator name="required">
        function () {
            // conditional stuff
            return result;
        }
    </aui:validator>