Skip to main content
Participant
Feb 24, 2020 4:56 PM UTC
Answered

Custom Validation Script with Pop-up Help

Hello there,

I am trying to create a pop up warning based on a validation calculation for a field. 

I have this so far: 

 

If(event.value(Hotel > (Lodging*nDays))) app.alert(“Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.”);

 

I'm getting a Syntax Error saying that I'm missing a before statement and I'm not sure how to move past this. I'm not a JavaScript person so I don't even know where to begin fixing this. Please help!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Feb 24, 2020 9:55 PM UTC

Yes, that is what I mean. If the alert is shown, another field should be made required.


Use this:

 

if (event.value>(v1*v2)) {
app.alert("Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.");
this.getField("LodgingExceptionDropdown").required = true;
} else {
this.getField("LodgingExceptionDropdown").required = false;
}

8 replies

try67
Community Expert
Community Expert
Feb 24, 2020 6:06 PM UTC

Please explain what the validation should be first.

Translate
Participant
Feb 24, 2020 6:37 PM UTC

Oh, sorry about that. I tried to write it into the code up above (in the IF statement).

 

I want the Hotel field to validate against a calculated value that draws from two other fields. The value I am looking for it to validate against is [Lodging] multiplied byt [nDays]. If the amount entered into the Hotel field is greater than the value of  "Lodging*nDays" then I want the pop up to appear. 

 

Hopefully I'm using the right wording.

Translate
try67
Community Expert
Community Expert
Feb 24, 2020 7:51 PM UTC

Do you also want to reject the value entered into the Hotel field in that scenario?

Translate