• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
1

How to check string in java scripts for pdf forms

Community Beginner ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

Hello, my question is how to check one string in one field for example:
if in fill_20 the string is "Sofia" or SOFIA or sOfia or all combinations with lowercase letters and uppercase letters and so..
If fill_20 is with content=Sofia and all combination with lowercase and  uppercase letters then in fill_30 write value 100 if the string is different than Sofia then in fill_30 write 80?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

The first two conditions will verify if the text is EXACTLY "Š”Š¾Ń„Šøя" (irrelevant of upper/lower-case letters). The third will will check if it is anywhere within the string (also case-insensitive). So if you want to allow for other characters (like a space or other text) then use only the third if-statement.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

In Adobe Acrobat DC you can use:

if ( testString.trim().toUpperCase() == "Š”ŠžŠ¤Š˜ŠÆ")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

Only this IF?

if ( testString.match(/сŠ¾Ń„Šøя/i) != null )

????

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

Yeah this is enought for me!!
Now really work.
Thanks!


var testString = this.getField("fill_6").valueAsString; 

if ( testString.match(/сŠ¾Ń„Šøя/i) != null )

{

event.value = 100;

}

else

{

event.value = 80;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2018 Jul 09, 2018

Copy link to clipboard

Copied

Hi tanerz18448860ā€‹,

perhaps this is also a good way for all Acrobat versions

var testString = this.getField("fill_6").valueAsString;

if ( testString.match(/\s?сŠ¾Ń„Šøя\s?/i) != null ) {

    event.value = 100;

} else {

    event.value = 80;

}

If so, have fun

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 10, 2018 Jul 10, 2018

Copy link to clipboard

Copied

I need help and today.

Now need to check strings with country if  in field 1 the country is USA  then in field 2 write 50, in field 3 write 80.
If the country in field 1 is  Brazil then in field 2 write 40, in field 3 write 70.
If the country in field 1 is Spain then in field 2 write 35 in field 3 write 65.
And so and so.


How can I modify this to work with many checks and if's functions?

var testString = this.getField("fill_6").valueAsString;

if ( testString.match(/сŠ¾Ń„Šøя/i) != null )

{

event.value = 100;

}

else

{

event.value = 80;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

I successfully do it  with to much IF'S.
But how can I do it with masives?


I do it with this codes and it's work..
var testString = this.getField("Dropdown7").valueAsString;

if ( testString.match(/ŠÆŠæŠ¾Š½Šøя/i) != null )

{

event.value = 5500;

}

if ( testString.match(/ŠŠ²ŃŃ‚Ń€Šøя/i) != null )

{

event.value = 35;

}

if ( testString.match(/ŠŠ²ŃŃ‚Ń€Š°Š»Šøя/i) != null )

{

event.value = 35;

}

if ( testString.match(/ŠŠ·ŠµŃ€Š±Š°Š¹Š“Š¶Š°Š½/i) != null )

{

event.value = 30;

}


I want to do it with masives:

I find this codes:

var c30 = ["Š—ŠøŠ¼Š±Š°Š±Š²Šµ", "Š—Š°Šøр", "Š•Ń‚ŠøŠ¾ŠæŠøя"];

var c35 = ["Š”Š°Š½Šøя", "Š“ърцŠøя", Š“ŠµŃ€Š¼Š°Š½Šøя];

var x = "Š—ŠøŠ¼Š±Š°Š±Š²Šµ";

var rez=0;

if(c30.indexOf(x)>=0){

rez = 30;

}

if(c35.indexOf(x)>=0){

rez = 35;

}

But ho can I implement it in java script in pdf forms?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

I tried this but it doesn't work:

var c30 = ["Š—ŠøŠ¼Š±Š°Š±Š²Šµ", "Š—Š°Šøр", "Š•Ń‚ŠøŠ¾ŠæŠøя"];

var c35 = ["Š”Š°Š½Šøя", "Š“ърцŠøя", Š“ŠµŃ€Š¼Š°Š½Šøя];

var x = "Š—ŠøŠ¼Š±Š°Š±Š²Šµ";

var rez=0;

if(c30.indexOf(x)>=0){

rez = 30;

{

event.value= 30;

}

}

if(c35.indexOf(x)>=0){

rez = 35;

{

event.value=35;

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

It should work, but this will only be for exact matches, ie it won't work if you add a space after the string.

If you want further help you really have to start providing more exact descriptions of the issues you're having. "It doesn't work" is meaningless to us.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

Why are you using the "rez" variable if you're applying the value to event.value directly? Get rid of rez and do it directly.

Also, you need to carefully look at the curly brackets in your code and make sure that they are set up correctly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

Okay, can you correct my code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

Try this:

var c30 = ["Š—ŠøŠ¼Š±Š°Š±Š²Šµ", "Š—Š°Šøр", "Š•Ń‚ŠøŠ¾ŠæŠøя"];

var c35 = ["Š”Š°Š½Šøя", "Š“ърцŠøя", "Š“ŠµŃ€Š¼Š°Š½Šøя"];

var x = "Š—ŠøŠ¼Š±Š°Š±Š²Šµ";

var rez = 0;

if (c30.indexOf(x)>=0){

    rez = 30;

} else if (c35.indexOf(x)>=0) {

    rez = 35;

}

event.value = rez;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

This code solve my problem:


var testString = this.getField("Dropdown7").valueAsString;

var c30 = ["Š—ŠøŠ¼Š±Š°Š±Š²Šµ", "Š—Š°Šøр", "Š•Ń‚ŠøŠ¾ŠæŠøя"];

var c35 = ["Š”Š°Š½Šøя", "Š“ърцŠøя", Š“ŠµŃ€Š¼Š°Š½Šøя];

if(c30.indexOf(testString)>=0){

event.value=30;

}

if(c35.indexOf(testString)>=0){

event.value=35;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

This is not a good solution. If the text in question is not in either of the arrays then the value of the field will just stay as it was before...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2018 Jul 11, 2018

Copy link to clipboard

Copied

LATEST

No, it's work, user select the country from dropdown field where I define the country names.

var testString = this.getField("Dropdown7").valueAsString;

var c30 = ["Š—ŠøŠ¼Š±Š°Š±Š²Šµ", "Š—Š°Šøр", "Š•Ń‚ŠøŠ¾ŠæŠøя", "ŠŠ·ŠµŃ€Š±Š°Š¹Š“Š¶Š°Š½","ŠŠ»Š±Š°Š½Šøя","ŠŃ€Š¼ŠµŠ½Šøя", "ŠŃ„Š³Š°Š½ŠøстŠ°Š½",

"Š‘Š°Š½Š³Š»Š°Š“ŠµŃˆ", "Š‘Š°Ń…Ń€ŠµŠ¹Š½", "Š‘ŠµŠ»Š¾Ń€ŃƒŃŠøя", "Š’ŠµŠ»ŠøŠŗŠ¾Š±Ń€ŠøтŠ°Š½Šøя", "Š’ŠøŠµŃ‚Š½Š°Š¼", "Š“Š°Š½Š°","Š“Ń€ŃƒŠ·Šøя", "Š”Ń€ŃƒŠ³Šø стрŠ°Š½Šø",

"Š•Š³ŠøŠæŠµŃ‚", "Š•ŃŃ‚Š¾Š½Šøя","Š˜Š½Š“Šøя", "Š˜Š½Š“Š¾Š½ŠµŠ·Šøя","Š˜Ń€Š°Šŗ", "Š˜Ń€Š°Š½", "Š™ŠµŠ¼ŠµŠ½", "Š™Š¾Ń€Š“Š°Š½Šøя", "ŠšŠ°Š·Š°Ń…стŠ°Š½", "ŠšŠµŠ½Šøя",

"ŠšŠøтŠ°Š¹", "ŠšŠŠ”Š ", "ŠšŠ¾Š»ŃƒŠ¼Š±Šøя", "ŠšŠ¾Ń€ŠµŃ", "ŠšŠ¾Ń‚ Š“'Š˜Š²Š¾Š°Ń€", "Š›ŠøŠ±Šøя", "Š›ŠøŠ²Š°Š½", "ŠœŠ°Š»Š°Š¹Š·Šøя", "ŠœŠ°Š»Šø",

"ŠœŠ°Ń€Š¾ŠŗŠ¾", "ŠœŠµŠŗсŠøŠŗŠ¾", "ŠœŠ¾Š·Š°Š¼Š±ŠøŠŗ", "ŠœŠ¾Š»Š“Š¾Š²Š°", "ŠœŠ¾Š½Š³Š¾Š»Šøя", "ŠŠøŠ³ŠµŃ€Šøя", "ŠŠøŠŗŠ°Ń€Š°Š³ŃƒŠ°", "ŠŠ¾Š²Š° Š—ŠµŠ»Š°Š½Š“Šøя",

"ŠžŠ±ŠµŠ“ŠøŠ½ŠµŠ½Šø Š°Ń€Š°Š±ŃŠŗŠø ŠµŠ¼ŠøрстŠ²Š°", "ŠŸŠ°ŠŗŠøстŠ°Š½", "ŠŸŠµŃ€Ńƒ", "Š”Š°ŃƒŠ“ŠøтсŠŗŠ° ŠŃ€Š°Š±Šøя", "Š”ŠøŠ½Š³Š°Šæур", "Š”ŠøрŠøя",

"Š¢Š°Š“Š¶ŠøŠŗŠøстŠ°Š½", "Š¢ŃƒŠ½Šøс", "Š¢ŃŽŃ€ŠŗŠ¼ŠµŠ½ŠøстŠ°Š½", "Š¢ŃƒŃ€Ń†Šøя", "Š£Š·Š±ŠµŠŗŠøстŠ°Š½", "Š£ŠŗрŠ°Š¹Š½Š°", "Š§ŠøŠ»Šø", "Š®ŠŠ "];

var c35 = ["Š”Š°Š½Šøя", "Š“ърцŠøя","Š“ŠµŃ€Š¼Š°Š½Šøя","ŠŸŠ¾Š»ŃˆŠ°","ŠŠ²ŃŃ‚Ń€Š°Š»Šøя / Australia", "ŠŠ»Š¶Šøр", "ŠŠ½Š³Š¾Š»Š°",

"ŠŃ€Š¶ŠµŠ½Ń‚ŠøŠ½Š° / Argentina", "Š‘ŠµŠ»Š³Šøя", "Š‘Š¾ŃŠ½Š°", "Š‘Ń€Š°Š·ŠøŠ»Šøя","Š“ŠøŠ±Ń€Š°Š»Ń‚Š°Ń€","Š˜Š·Ń€Š°ŠµŠ»", "Š˜Ń€Š»Š°Š½Š“Šøя",

"Š˜ŃŠ»Š°Š½Š“Šøя", "Š˜ŃŠæŠ°Š½Šøя", "Š˜Ń‚Š°Š»Šøя", "ŠšŠ°Š½Š°Š“Š°", "ŠšŃƒŠæър", "ŠšŃƒŠ±Š°", "ŠšŃƒŠ²ŠµŠ¹Ń‚", "Š›Š°Ń‚Š²Šøя", "Š›ŠøтŠ²Š°",

"Š›ŠøхтŠµŠ½Ń‰Š°Š¹Š½", "Š›ŃŽŠŗсŠµŠ¼Š±ŃƒŃ€Š³", "ŠœŠ°ŠŗŠµŠ“Š¾Š½Šøя", "ŠœŠ°Š»Ń‚Š°", "ŠœŠ¾Š½Š°ŠŗŠ¾","ŠŠ¾Ń€Š²ŠµŠ³Šøя", "ŠŸŠ¾Ń€Ń‚ŃƒŠ³Š°Š»Šøя",

"Š ŃƒŠ¼ŃŠŠ½Šøя", "Š ŃƒŃŠøя", "Š”Š°Š½ ŠœŠ°Ń€ŠøŠ½Š¾", "Š”ŠŠ©", "Š”Š»Š¾Š²Š°ŠŗŠøя", "Š”Š»Š¾Š²ŠµŠ½Šøя", "Š£Š½Š³Š°Ń€Šøя", "Š¤ŠøŠ½Š»Š°Š½Š“Šøя",

"Š¤Ń€Š°Š½Ń†Šøя", "Š„Š¾Š»Š°Š½Š“Šøя", "ŠØŠ²ŠµŃ†Šøя", "Š§ŠµŃ…Šøя", "Š®Š³Š¾ŃŠ»Š°Š²Šøя" ];

var c60 = ["ŠØŠ²ŠµŠ¹Ń†Š°Ń€Šøя"];

var c5500 = ["ŠÆŠæŠ¾Š½Šøя"];

if(c30.indexOf(testString)>=0)

{

event.value=30;

}

if(c35.indexOf(testString)>=0)

{

event.value=35;

}

if(c60.indexOf(testString)>=0)

{

event.value=60;

}

if(c5500.indexOf(testString)>=0)

{

event.value=5500

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines