I need to validate my forms in LifeRay portlet. After some research I understands that LifeRay has 2 ways to validate form: using Alloy UI taglibs and using Alloy UI javascript library. And using taglibs it is the old way (please correct me if I'm wrong).
So I want to make validation using Alloy UI Javascript library. But how I can include it to portlet? As I understand the Alloy UI JS library is bundled with LifeRay since 6.x version. May be I need to specify <header-portlet-css>
and <header-portlet-javascript>
? Because it seems Alloy UI didn't included to each portlet automatically.
This is a sample.
Insert in you portlet JSP the alloyui taglib with the right use attribute to have within the context the A.FormValidator
object:
<aui:script use="aui-form-validator">
var validator = new A.FormValidator({
boundingBox: form,
rules: {
'<portlet:namespace />emailAddress': {
email: true
},
'<portlet:namespace />countryId': {
required: true
}
},
strings: {
required: '<liferay-ui:message key="this-field-is-required" />'
}
});
</aui:script>