Fórum

Field validation

thumbnail
sujay paul, modificado 11 Anos atrás.

Field validation

Regular Member Postagens: 164 Data de Entrada: 28/10/11 Postagens Recentes
Hi,

In create account page if i skip the first name then it will give an error message "First Name Required " .

Is it possible to do this type of validation for custom field ?

Please help.

thumbnail
Subhash Pavuskar, modificado 11 Anos atrás.

RE: Field validation

Regular Member Postagens: 234 Data de Entrada: 13/03/12 Postagens Recentes
You can do this validation by JavaScript here is an example Click here
thumbnail
sujay paul, modificado 11 Anos atrás.

RE: Field validation

Regular Member Postagens: 164 Data de Entrada: 28/10/11 Postagens Recentes
Thanks Subhash

But i have add this code for custom fields

<liferay-ui:custom-attribute
className="com.liferay.portal.model.User"
classPK="<%= 0l %>"
editable="<%= true %>"
label="<%= true %>"
name="Phone No"
/>

where & how should i add the js

thanks in advance.
thumbnail
Subhash Pavuskar, modificado 11 Anos atrás.

RE: Field validation

Regular Member Postagens: 234 Data de Entrada: 13/03/12 Postagens Recentes
Hi,

One of the clean ways to include js file in a portlet, independent of the portal server is to configure in
portlet deployment descriptor file as below i.e liferay-portlet.xml.

<portlet>
    <portlet-name>MySamplePortlet</portlet-name>
    <header-portlet-javascript> </header-portlet-javascript>
</portlet>
thumbnail
sujay paul, modificado 11 Anos atrás.

RE: Field validation

Regular Member Postagens: 164 Data de Entrada: 28/10/11 Postagens Recentes
<liferay-ui:custom-attribute onclick="validate()"
className="com.liferay.portal.model.User"
classPK="<%= 0l %>"
editable="<%= true %>"
label="<%= true %>"
name="Phone No"
/>

its not working
Akram MONCER, modificado 11 Anos atrás.

RE: Field validation

Regular Member Postagens: 106 Data de Entrada: 25/09/12 Postagens Recentes
look at this blog i think it can help : http://drewblessing.com/blog/-/blogs/34509
thumbnail
sujay paul, modificado 11 Anos atrás.

RE: Field validation

Regular Member Postagens: 164 Data de Entrada: 28/10/11 Postagens Recentes
Thanks Akram
This <aui:validator> is applicable for <aui:input>.
I need validator for <liferay-ui:custom-attribute>
thumbnail
Apoorva Prakash, modificado 11 Anos atrás.

RE: Field validation

Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens Recentes
sujay paul:
Thanks Akram
This <aui:validator> is applicable for <aui:input>.
I need validator for <liferay-ui:custom-attribute>

Hello Sujay,

Hope this will help...

<aui:script use="liferay-form">
        Liferay.Form.register(
            {
                id: '<portlet:namespace />fm',
                fieldRules: [
                    {
                        body: '',
                        custom: false,
                        errorMessage: 'Please enter the company name.',
                        fieldName: '<portlet:namespace />ExpandoAttributeName',
                        validatorName: 'required'
                    }
                ]
            }
        );
    </aui:script>


Thanks and Regards,
Apoorva Prakash