Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sujay Kumar Paul
Field validation
January 20, 2013 11:03 PM
Answer

Sujay Kumar Paul

Rank: Regular Member

Posts: 147

Join Date: October 28, 2011

Recent Posts

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.

Subhash Pavuskar
RE: Field validation
January 21, 2013 6:16 AM
Answer

Subhash Pavuskar

Rank: Regular Member

Posts: 216

Join Date: March 12, 2012

Recent Posts

You can do this validation by JavaScript here is an example Click here
Sujay Kumar Paul
RE: Field validation
January 21, 2013 10:45 PM
Answer

Sujay Kumar Paul

Rank: Regular Member

Posts: 147

Join Date: October 28, 2011

Recent Posts

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.
Subhash Pavuskar
RE: Field validation
January 21, 2013 10:57 PM
Answer

Subhash Pavuskar

Rank: Regular Member

Posts: 216

Join Date: March 12, 2012

Recent Posts

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.

1<portlet>
2    <portlet-name>MySamplePortlet</portlet-name>
3    <header-portlet-javascript> </header-portlet-javascript>
4</portlet>
Sujay Kumar Paul
RE: Field validation
January 22, 2013 5:02 AM
Answer

Sujay Kumar Paul

Rank: Regular Member

Posts: 147

Join Date: October 28, 2011

Recent Posts

<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
RE: Field validation
January 22, 2013 12:00 PM
Answer

Akram MONCER

Rank: Regular Member

Posts: 106

Join Date: September 25, 2012

Recent Posts

look at this blog i think it can help : http://drewblessing.com/blog/-/blogs/34509
Sujay Kumar Paul
RE: Field validation
January 25, 2013 3:38 AM
Answer

Sujay Kumar Paul

Rank: Regular Member

Posts: 147

Join Date: October 28, 2011

Recent Posts

Thanks Akram
This <aui:validator> is applicable for <aui:input>.
I need validator for <liferay-ui:custom-attribute>
Apoorva Prakash
RE: Field validation
January 25, 2013 6:52 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 658

Join Date: June 15, 2010

Recent Posts

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...

 1<aui:script use="liferay-form">
 2        Liferay.Form.register(
 3            {
 4                id: '<portlet:namespace />fm',
 5                fieldRules: [
 6                    {
 7                        body: '',
 8                        custom: false,
 9                        errorMessage: 'Please enter the company name.',
10                        fieldName: '<portlet:namespace />ExpandoAttributeName',
11                        validatorName: 'required'
12                    }
13                ]
14            }
15        );
16    </aui:script>


Thanks and Regards,
Apoorva Prakash