Textfield Uniqueness | Community
Skip to main content
narayanank84409
Level 4
October 16, 2015
Solved

Textfield Uniqueness

  • October 16, 2015
  • 3 replies
  • 898 views

Hi Team,

I have multifield, under that i gave textfield.

user can enter value multiple times in textfield, that time how i can check uniqueness in value.

Example:

Multifield

1. textfield -- example.

2. textfield - example1

3. textfield - example(if user enters the same value, i need to show error message as enter different value).

Please provide some material or suggestions, it would be great help for me.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

Hi,

If you see the documentation for textfield [1], you will find 1 helpful listener waiting for you there:

blurFires when this field loses input focus

Apart from this you can also implement beforesubmit ( fires when you submit the dialog, add you logic for checking randomness and return true or false accordingly, that it ) listener available for dialog

[1] http://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Ext.form.TextField

Thanks

3 replies

edubey
edubeyAccepted solution
Level 10
October 16, 2015

Hi,

If you see the documentation for textfield [1], you will find 1 helpful listener waiting for you there:

blurFires when this field loses input focus

Apart from this you can also implement beforesubmit ( fires when you submit the dialog, add you logic for checking randomness and return true or false accordingly, that it ) listener available for dialog

[1] http://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Ext.form.TextField

Thanks

Lokesh_Shivalingaiah
Level 10
October 16, 2015

you have to write a listener and check the value of each field. refer [1] to know about listeners

[1] https://docs.adobe.com/docs/en/aem/6-0/develop/components/widgets.html

smacdonald2008
Level 10
October 16, 2015

You can code a custom xtype that uses a multifield. THen you can - in the JS file - read the values that the author enters into the textfield and process it to meet your business requirements. 

For example -- see how we handle  textfield (type CQ.Ext.form.TextField) - in the JS file in this article: 

Creating Adobe Experience Manager Components that use Standard Tag Libraries

Notice how we can use events to modify values (This is how you can control text values used in a component's dialog  ). For example:  

 // overriding CQ.form.CompositeField#getRawValue

        getRawValue: function() {
            if (!this.devWeapon){
                return null;
            }
            var title = this.nameField.getValue();
            var image = this.devImage.getValue();
            var link = this.codeName.getValue();
            var target = this.devWeapon.getValue();
            var altText = this.devDesc.getValue();
 
            if (title == '')
                title = " ";
            if (link == '')
                link = " ";
            if (target == '')
                target = " ";
            if (altText == '')
                altText = " ";
               var value = title + "|" + image + "|" + link + "|" + target + "|" + altText;
            this.hiddenField.setValue(value);
            return value;
        },