Expand my Community achievements bar.

Remove everything after first commas (,) from string

Avatar

Level 1

I have textfield1 and textfield2, I want to reduce characters after commas in textfield2

example:

textfield1 =

This is mango, the color is green

in textfield2 =

this is mango

I want to use if with initialization / trigger "comma (,)"

If in php like this :

remove everything after first comma from string in php - Stack Overflow

How i write in adobe live cycle

please help if anyone understands in adobe live cycle

3 Replies

Avatar

Level 10

Hi,

In JavaScript you could use "textfield2.rawValue = "This is mango, the color is green".split(",")[0]"

Which turns your string into an array split on the comma and then you take the first one.

Avatar

Level 1

I want to make it automatic with various kinds of long characters

When i write in textfield1 , so textfield2 automatic corection after comma will be remove

How do i write the code ? Do use ...If...Else ?

Avatar

Level 10

I am not sure what you mean by "various kinds of long characters".  But for the example you have you could put the following line of JavaScript code in the calculate event of textfield2

textfield1.rawValue.split(",")[0]

This assumes that textfield2 and textfield1 are at the same level in the form structure as the textfield1 is a relative reference.