Jump to content

rule that ignores initial caps or all-caps user input

Recommended Posts

I have a graphic rule that allows a user to enter a name in a variable data field and if it matches a what I want it to, it'll return a graphic- -


if (Field("Dealership Name").indexOf(String("Acura")) > -1)


return Resource("Acura.png");


but I want to allow for the possibility that a user may type in all caps or initial caps and or all lower case. As long as the it matches the words, I don't care about the case. How do I amend this rule to do that?


also, what does that "> -1" mean in the first line?





Link to comment
Share on other sites

you could change your IF statement to

if (Field("Dealership Name").toLowerCase().indexOf("acura") > -1)


The toLowerCase method converts your field value to all lowercase which you compare to an all-lowercase string in your indexOf method.


The indexOf method returns the start position of the string you're looking for in the string you're searching. A value of "-1" is returned if there is no match while a value of zero or greater is returned if the string does exist. So the code above is essentially saying "if the string exists anywhere in field value".

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...