• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hello. i have varv1 and varv2.

Explorer ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

Hello. i have varv1 and varv2. and i want varv2<=varv1 if not it wrong

I START LIKE THIS

// Get field values as numbers

    var v1 = +getField("Textfield66").value;

    var v2 = +getField("Textfield67").value;

how can i end it?

Thanks

TOPICS
Acrobat SDK and JavaScript

Views

688

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

correct answers 1 Correct answer

Community Expert , Feb 02, 2018 Feb 02, 2018

Add this at the end of your code:

if (v2<=v1) app.alert("Error! v2<=v1");

Votes

Translate

Translate
Community Expert ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

What exactly do you want to happen if v2<=v1?

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
Explorer ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

it is not allowed v2>=v1 for example if v1=100 and v2=200 this is wrong

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
Explorer ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

maby if this will happent ,a note( v2<=v1) will apear

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 ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

Add this at the end of your code:

if (v2<=v1) app.alert("Error! v2<=v1");

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
Explorer ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

it is ok.The warning is Error v2<=v2.how can we make it like this: Error 612<=611

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 ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

if (v2<=v1) app.alert("Error! "+v2+"<="+v1);

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
Explorer ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

611 and 612 is a numbering

Exactly

611

200

612

300

 

the number which is included in cell 612 must <=611

so as the example the value of cell 612(300) is >611 and it is wrong

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
Explorer ,
Feb 02, 2018 Feb 02, 2018

Copy link to clipboard

Copied

see 611 612 as names

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
LEGEND ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

You know the limits so you must write the code to follow the rules you set.

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 ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

It's really not that complicated...

if (v2<=v1) app.alert("Error! 611<=612");

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
Explorer ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

ok thank you very much it was so easy.Now i have a new problem.I made the same for other Textfields. For example I already have 611 and 612  and then i create 613 and 614(i use the same script) and all the warnings apear.It is crazy.

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 ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

Where did you place the 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
Explorer ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

to the calculation script

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 ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

That event is executed each time the value of any field in the file is changed.

Try using the custom validation script. However, if you do that then you need to use event.value to access the new value of that field, instead of this.getField("").value ...

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
Explorer ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

i am so confused.I used this script

// Get field values as numbers

    v1 = +getField("Textfield66").value;

    v2 = +getField("Textfield67").value;

if (v2>=v1) app.alert("Error! 612 μεγαλύτερο του 611"); in which point i will put event.value?

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 ,
Feb 03, 2018 Feb 03, 2018

Copy link to clipboard

Copied

If you're using it to validate the value of "Textfield67" then replace this line:

v2 = +getField("Textfield67").value;

With:

v2 = +event.value;

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
Explorer ,
Feb 04, 2018 Feb 04, 2018

Copy link to clipboard

Copied

PERFECT!!!!!!!!!

One more question.This allows users to move on.How can we exlude it if it is wrong?

Thanks.

PS1.Wish we meet each other one day to offer you my own local samos island wine.

PS2.I am interested for adobe javascript lessons.Do you know how can i start and what ammount is required?

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 ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

It's not a good idea to prevent someone from moving to a different field. A better approach is to reject their value.

To do that use this code:

if (v2>=v1) {

     app.alert("error message");

     event.rc = false;

}

1. Sounds good! Εβίβα!

2. Follow these resources to learn more about Acrobat JS:

http://www.adobe.com/devnet/acrobat.html

https://acrobatusers.com/tutorials/

http://www.pdfscripting.com/

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
Explorer ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

Thank you veru much.It works really nice.

if i want to do the same for sum is this correct?

if {v6>=(v1+v2+v3+v4+v5)}

and i used format script with persentage

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 ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

Almost. The if-condition must be inside normal parentheses. The curly ones are used to define a block of code that is treated as one unit.

So it needs to be:

if (condition) {

     code to be executed in case the condition is true;

}

It should work fine with percentages, but keep in mind that the percentage value appears as a number between 0 and 100, but in fact it's between 0 and 1.

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
Explorer ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

what about this

// Get field values as numbers

    v1 = +getField("Textfield28").value;

v2 = +getField("Textfield34").value;v3 = +getField("Textfield40").value;v4 = +getField("Textfield46").value;v5 = +getField("Textfield52").value;

v6 = +event.value;

if ((v6>(v1+v2+v3+v4+v5)){ app.alert("ΛΑΘΟΣ! 612 μεγαλύτερο του 611 οι Εισαγωγές αγαθών εντός του ομίλου πρέπει να είναι μικρότερες η ίσες με τις Συνολικές Εισαγωγές αγαθών");

event.rc = false;

}

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 ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

That should work.

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
Explorer ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

unfortunately is not working

SyntaxError: missing ) after condition

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
LEGEND ,
Feb 05, 2018 Feb 05, 2018

Copy link to clipboard

Copied

Hello klothos,

as a beginner in js: Would you please publish a link to your website in question for me where you use all these js-features.

Thanks in advance

Hans-Günter

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