Search only partial textField rawValue

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

04-10-2016

My form has a textField that users enter part numbers separated by commas. I want to write an if statement that looks to see if one of the part numbers is included in the list. Is there a way to script to search for only part of a textField's rawValue or formattedValue?

So if the rawValue of textField1 is 1234, 4569, 3582

I want to be able to enter 4569 in textField2 (a different textField)  and click a button that runs a script to see if 4569 is included in the list of part numbers.

Is this possible?

Also: is it possible to send the comma separated part numbers to a list box?

I appreciate any help provided.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

04-10-2016

Here you go:

var aWords = TextField1.rawValue.split(","),

  cTest = this.rawValue,

  isIncluded = function (value) {

    return value.replace(/\s/g, "") == this.testValue.replace(/\s/g, "");

  },

  toTest = {

    testValue : cTest

  },

  iCount = 0;

// Check all words against the entered value

if (aWords.some(isIncluded, toTest) === true) {

  iCount += 1;

}

// Show a message, if the word was found

if (iCount > 0) {

  xfa.host.messageBox("The word '" + cTest + "' is already included in the list.", "Match found.", 0, 0)

}

Answers (5)

Answers (5)

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

04-10-2016

The examples look very interesting. It will take some looking thru. Thank you for sending this information.

-Don

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

04-10-2016

There is a nice sample from Bruce which shows how to update the contents of RichText fields.

Adobe LiveCycle Designer Cookbooks by BR001: Programmatically updating Rich Text (or xHTML)

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

04-10-2016

Thanks for your help.

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

04-10-2016

I think highlighting the field would be really difficult to do. First the field would have to be set as rich text then you would need a method to change the fields color and background within that field. I guess you could grab the field data, and write it back out highlighting the string in question.

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

04-10-2016

This script works great! Thank you

Is there a way to highlight the part number in the list that was found?