Skip to main content
August 17, 2022
Answered

If two fields have data then

  • August 17, 2022
  • 2 replies
  • 438 views

Hello, I need help.  I am working on creating some error checks so I can reduce the need to return a form for revisions.

 

I am trying to write JavaScript to compare two fields "*S2 HR Meal Count" and "*S2 LR Meal Count."  Both fields cannot have information in them, if they do then I need to return a message of "Cannot have both High Rate and Low Rate."  Below is what I have come up with...

 

if (this.getfield("*S2 HR Meal Count").value >0 && EC5 = this.getfield("*S2 LR Meal Count").value >0) event.value ="Cannot have both High Rate and Low Rate.";
else event.value ="";

 I am getting an error in the JavaScript editor.  I don't know enough about this to know what I am doing wrong.  I'm learning as I go.  I've look at a lot of other posts and can't find something that matches what I'm trying to do.  

 

Yes, I know that my field names aren't the smartest, but it was before I started writing JavaScript.

 

Thanks in Advance for your help.

This topic has been closed for replies.
Correct answer try67

There are multiples errors in your code.

1. It's getField, not getfield... JS is case-sensitive.

2. Why are you declaring the EC5 variable in the middle of the if-condition? Remove it from there.

2 replies

Bernd Alheit
Community Expert
Community Expert
August 17, 2022

Use getField, not getfield

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 17, 2022

There are multiples errors in your code.

1. It's getField, not getfield... JS is case-sensitive.

2. Why are you declaring the EC5 variable in the middle of the if-condition? Remove it from there.