Skip to main content
Participant
February 24, 2020
Answered

Custom Validation Script with Pop-up Help

  • February 24, 2020
  • 1 reply
  • 1414 views

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 has been closed for replies.
Correct answer try67

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;
}

1 reply

try67
Community Expert
Community Expert
February 24, 2020

Please explain what the validation should be first.

Participant
February 24, 2020

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.

try67
Community Expert
Community Expert
February 24, 2020

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