Skip to main content
steft66579364
Known Participant
March 10, 2017
Answered

I have a 2 fields that are compared and the result is put into a 3rd field, the result can be a positive number or a negative number. If the result is bigger than (-) 6 or 6 , I want to populate another field with fail

  • March 10, 2017
  • 1 reply
  • 718 views

Hello,

I need help with the following

I have a 2 fields that are compared ( if / else) and the result is put into a 3rd field, the result can be a positive number or a negative number. If the result is bigger than 6 or 6 , I want to populate another field with fail.

I have search  the forums and other sites for an answer but without any solution

Any help would be appreciated

Thank you

This topic has been closed for replies.
Correct answer try67

You can use this code for the fourth field:

event.value = (Math.abs(Number(this.getField("sum").value)) >= 6) ? "Pass" : "Fail";

Edit: fixed code

1 reply

try67
Community Expert
Community Expert
March 10, 2017

And if the value is between 6 and -6, what should the text field show? What about if it's empty?

steft66579364
Known Participant
March 10, 2017

Hello,

If the answer is 5 and or -5 the field should show pass ,never empty

Thanks

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 10, 2017

You can use this code for the fourth field:

event.value = (Math.abs(Number(this.getField("sum").value)) >= 6) ? "Pass" : "Fail";

Edit: fixed code