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.");
}
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
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
Copy link to clipboard
Copied
Oh I was sure I tried it before, guess I didn't 🙂 thanks that helped a lot.
Copy link to clipboard
Copied
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 =""; }
}