Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Sujay Kumar Paul
Field validation
20. Januar 2013 23:03
Antwort

Sujay Kumar Paul

Rang: Regular Member

Nachrichten: 165

Eintrittsdatum: 28. Oktober 2011

Neue Beiträge

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
21. Januar 2013 06:16
Antwort

Subhash Pavuskar

Rang: Regular Member

Nachrichten: 234

Eintrittsdatum: 12. März 2012

Neue Beiträge

You can do this validation by JavaScript here is an example Click here
Sujay Kumar Paul
RE: Field validation
21. Januar 2013 22:45
Antwort

Sujay Kumar Paul

Rang: Regular Member

Nachrichten: 165

Eintrittsdatum: 28. Oktober 2011

Neue Beiträge

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
21. Januar 2013 22:57
Antwort

Subhash Pavuskar

Rang: Regular Member

Nachrichten: 234

Eintrittsdatum: 12. März 2012

Neue Beiträge

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
22. Januar 2013 05:02
Antwort

Sujay Kumar Paul

Rang: Regular Member

Nachrichten: 165

Eintrittsdatum: 28. Oktober 2011

Neue Beiträge

<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
22. Januar 2013 12:00
Antwort

Akram MONCER

Rang: Regular Member

Nachrichten: 106

Eintrittsdatum: 25. September 2012

Neue Beiträge

look at this blog i think it can help : http://drewblessing.com/blog/-/blogs/34509
Sujay Kumar Paul
RE: Field validation
25. Januar 2013 03:38
Antwort

Sujay Kumar Paul

Rang: Regular Member

Nachrichten: 165

Eintrittsdatum: 28. Oktober 2011

Neue Beiträge

Thanks Akram
This <aui:validator> is applicable for <aui:input>.
I need validator for <liferay-ui:custom-attribute>
Apoorva Prakash
RE: Field validation
25. Januar 2013 06:52
Antwort

Apoorva Prakash

Rang: Liferay Master

Nachrichten: 659

Eintrittsdatum: 15. Juni 2010

Neue Beiträge

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