Skip to main content
Aug 17, 2022 7:24 PM UTC
Answered

If two fields have data then

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Aug 17, 2022 7:54 PM UTC

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
Aug 17, 2022 7:54 PM UTC

Use getField, not getfield

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Aug 17, 2022 7:54 PM UTC

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.

Translate