Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How to add prefix to entere value?

Avatar

Level 4

Sir

in textfield display pattern any way to add a prefix in textfield

i try it

text{'Name' AAAAAAAAAAAAAAAAAA}

BUT when name in two words (e.g. Michal Shumakar) its not worked.

7 Replies

Avatar

Level 10

The 'A' symbol will match alphabetic characters, which the space character is not.

You could try text{'Name ' XXXXXXXXXXXXXXX} which will work for "Michal Shumakar", 'X' matches any character, but will only match a 14 character value.

You probably want to try doing this in code.

Avatar

Level 4

any other way to add a prefix in a textfield at runtime.

Avatar

Level 4

WHEN I select email alphanumeric pattern  

its work fine when less than 14 characters text{OOOOOOOOOOOOOO'@example.com'}

but not working in case of   text{'Name ' XXXXXXXXXXXXXXX}

Avatar

Level 10

You can create the pattern depending on the length of the input string dynamically.

Add this script to the fields exit event:

if (!this.isNull) {

    this.format.picture.value = "text{'Name '" + new Array(this.rawValue.length + 1).join("X") + "}";

}

Avatar

Level 4

any short script for this dispaly pattern

null{'Name :'}|text{'Name : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' '}

Avatar

Level 10

It's almost the same:

if (!this.isNull) {

    this.format.picture.value = "text{'Name: '" + new Array(this.rawValue.length + 1).join("X") + "}";

} else {

    this.format.picture.value = "null{'Name: '}";

}