Skip to main content
Participant
August 23, 2023
Answered

JavaScript for a product of two fields, but return blank if 0

  • August 23, 2023
  • 1 reply
  • 527 views

Hi, 

I am trying to create a javascript that has a product of two fields; field 1 "AHPRICE1" and field 2 "AH1", but if the product of those two fields is "0" I would like it to have a blank field. 

 

Can someone help with this?

This topic has been closed for replies.
Correct answer Nesa Nurani

To calculate product use, built in calculation, go to calculate tab, select 'Value is the' and from dropdown select product(x) and pick your two fields.

As 'Validate' script of same field, use this:

if(event.value == 0) event.value = "";

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 23, 2023

To calculate product use, built in calculation, go to calculate tab, select 'Value is the' and from dropdown select product(x) and pick your two fields.

As 'Validate' script of same field, use this:

if(event.value == 0) event.value = "";

Participant
August 23, 2023

I have entered the Validate Script, however I'm still getting $0.00 in the field. is there something I have in the format that is causing this to not show a blank in the field?

try67
Community Expert
Community Expert
August 23, 2023

You need to change the value of one of the fields for it to "kick in". If you did that and it's still not working properly, please share the file for further help.