Copy link to clipboard
Copied
I am trying to figure out how to check a certain textbox contains a certain word in either upper or lowercase (XPO). If it does, then perform one action. If not then perform a different action, below is the code i currently am working with but it dosent seem to work.
var cCustomerName = this.getField("CUSTOMER NAME").value;
if (cCustomerName == "XPO"||"xpo"){
ccAddress1 = ("dan.somename@somewhere.com" + "; " + "eps@somewhere.com" + "; " + "mark.b@somewhere.com" + "; " +"jeff.s@somewhere.com")
}
else
The best way to perform a test on text, is with a Regular Expression:
https://acrobatusers.com/tutorials/text-matching-regular-expressions
If XPO is this only word in the field, then this test will work
if(/^xpo$/i.test(cCustomerName))
{
.. Do stuff ...
}
But if XPO is only part of the text, then this will work
if(/xpo/i.test(cCustomerName))
{
.. Do stuff ...
}
If XPO needs to be a whole word in the text, then use this
if(/\wxpo\w/i.test(cCustomerName))
{
.. Do stuff ...
}
Copy link to clipboard
Copied
The best way to perform a test on text, is with a Regular Expression:
https://acrobatusers.com/tutorials/text-matching-regular-expressions
If XPO is this only word in the field, then this test will work
if(/^xpo$/i.test(cCustomerName))
{
.. Do stuff ...
}
But if XPO is only part of the text, then this will work
if(/xpo/i.test(cCustomerName))
{
.. Do stuff ...
}
If XPO needs to be a whole word in the text, then use this
if(/\wxpo\w/i.test(cCustomerName))
{
.. Do stuff ...
}
Copy link to clipboard
Copied
Thanks Thom, this seems to work out well. I would have never figured it out and it works for any combination whether it be caps or lowercase. Perfect!!