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

app.alert

Explorer ,
Aug 19, 2020 Aug 19, 2020

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
956
Translate
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

Translate
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

Translate
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

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

Translate
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 ,
Aug 19, 2020 Aug 19, 2020
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 =""; }
 
 }

 

 

Translate
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