Expand my Community achievements bar.

SOLVED

Textfield Uniqueness

Avatar

Level 4

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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

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

Avatar

Level 10

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

Avatar

Level 10

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;
        },