Skip to main content
Known Participant
August 19, 2020
Answered

app.alert

  • August 19, 2020
  • 1 reply
  • 1128 views

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.");
}

This topic has been closed for replies.
Correct answer BarlaeDC

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

1 reply

BarlaeDC
Community Expert
BarlaeDCCommunity ExpertCorrect answer
Community Expert
August 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

MarietaaAuthor
Known Participant
August 19, 2020

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

ls_rbls
Community Expert
Community Expert
August 19, 2020

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 =""; }
 
 }