Remove everything after first commas (,) from string

Avatar

Avatar

Ninarni

Avatar

Ninarni

Ninarni

12-08-2018

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

13-08-2018

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.

Avatar

Avatar

Ninarni

Avatar

Ninarni

Ninarni

13-08-2018

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

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

12-08-2018

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.