Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

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: '}";

}