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

app.alert

Explorer ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

Hi,

I have field1 and 2. I have app.alert if both fields are 0 I get app.alert,
but if only 1 is not 0 alert shouldn't pop.
I'm getting alert until both field are not 0. How do i fix it?


if(this.getField("field1").value == 0 || this.getField("field2").value == 0 ) {
app.alert("Field1 or field2 need value greater then 0.");
}

TOPICS
Acrobat SDK and JavaScript

Views

85

Likes

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 , Aug 19, 2020 Aug 19, 2020

HI,

 

I think you are looking for AND rather than OR in your if statement :

 

if(this.getField("field1").value == 0 && this.getField("field2").value == 0 ) {
app.alert("Field1 or field2 need value greater then 0.");
}

 

Hope this helps

 

Malcolm

Likes

Translate

Translate
Community Expert ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

HI,

 

I think you are looking for AND rather than OR in your if statement :

 

if(this.getField("field1").value == 0 && this.getField("field2").value == 0 ) {
app.alert("Field1 or field2 need value greater then 0.");
}

 

Hope this helps

 

Malcolm

Likes

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

Oh I was sure I tried it before, guess I didn't 🙂 thanks that helped a lot.

Likes

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

LATEST

A custom validation script  also worked for me:

 

 

if ( (event.value ==0) ||  ( this.getField("field2").value == 0 )) {

    app.alert("Invalid value for field. Field1 or field2 need a value greater than 0.");
    
     {if (event.value ==0) event.value =""; }
 
 }

 

 

Likes

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