Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Ignore case

Avatar

Level 9

Is there a way to have the script ignore upper and lower case?

I have a script that creates an array of the dropdown items then compares the users input to see if there is a match. The user needs to know to capitilize the first letter or a match will not be found. I want the script to find a match even if they do not capitalize the first letter. here's the script:

// Check that the user has not typed in a value
// that does not exist in the list. If they have
// then clear the dropdown.

// First create an array of the items in the
// dropdown list.
var vUserInput = [];
for (var i=0; i<this.length; i++) {
vUserInput.push(this.getDisplayItem(i));
}

// Check that the value is not in the array
if (this.rawValue !== null && vUserInput.lastIndexOf(this.rawValue) === -1) {
this.rawValue = null; // clear the dropdown
xfa.host.beep("3"); // audio alert to the user
this.ui.oneOfChild.border.fill.color.value = "255,225,225"; // red
}

1 Accepted Solution

Avatar

Correct answer by
Level 10

OK,

then you can use the sample from Bruce, which already does what you're looking for.

http://forums.adobe.com/message/2372156#2372156#2372156#2372156 (it's the countries.pdf and xml)

View solution in original post

11 Replies

Avatar

Level 8

Why not just uppercase or lowercase the values when comparing then you don't have to worry about the case the user enters

Avatar

Level 9

I guess I am not sure how to do what you are suggesting. Are you saying to write a script that changes the users entry to upper case and then one that changes it to lower case? and compare both?

What function/script changes the case of the users entry?

Avatar

Level 9

I tried the following but it does not work.

var vUserInput = toTitleCase([]);

for (var i=0; i<this.length; i++) {

vUserInput.push(this.getDisplayItem(i));

}

Avatar

Level 8

this.getDisplayItem(i).toUpperCase() will push the uppercase into the array.  Then the compare would be to  this.rawValue.toUpperCase().  Thus the compare would be all uppercase removing the case sensitivity

Avatar

Level 9

This is what I have but I can't get it to work... what do I have wrong?

var vUserInput = [];
for (var i=0; i<this.length; i++) {
vUserInput.push(this.getDisplayItem(i).toUpperCase());
}

// Check that the value is not in the array
if (this.rawValue !== null && vUserInput.lastIndexOf(this.rawValue.toUpperCase()) === -1) {
this.rawValue = null; // clear the dropdown
xfa.host.beep("3"); // audio alert to the user
this.ui.oneOfChild.border.fill.color.value = "255,225,225"; // red

Avatar

Level 9

I seperated the top section of the script from the bottom and this part will not work.

var vUserInput = [];

for (var i=0; i<this.length; i++){

vUserInput.push(this.getDisplayItem(i).toUpperCase());

}

Can you help?

Avatar

Level 9

Can anyone help me with this?

Avatar

Level 10

What are you trying to do with your dropdown?

Do you want something like a find-as-type method?

Does the dropdown allow custom entries?

Avatar

Level 9

Yes - I have script that opens the dropdown list when the focus is on that dropdown object. We need the user to be able to start typing the first letter or two to shorten the list. We wanted it to work regardless if they type lower or uppercase letters. Yes - it allows custom entries.

Avatar

Correct answer by
Level 10

OK,

then you can use the sample from Bruce, which already does what you're looking for.

http://forums.adobe.com/message/2372156#2372156#2372156#2372156 (it's the countries.pdf and xml)