Copy link to clipboard
Copied
Experts,
The below script is partially working. I have a checkbox, "401k50", with a value of 0 or 1 (if checked). If checked, if in a different field User enters a number greater than 24500, the alert pops up and tells them the must enter a number between 0 and 24500. This works. So far so good. If the box, 401k50 is unchecked, and User enters a number greater than 18500, an alert box is supposed to tell User to enter a number between 0 and 18500. This is not working. Currently, if unchecked, user is able to enter any number he wishes. Here's my script:
//401k50 is a checkbox, value of 1 if checked, 0 if unchecked
var v1 = +getField("401k50").value;
//Checkbox is checked
if(v1 > 0){
var v2 = +event.value;if (v2 > 24500) {
app.alert("Since you are over 50 you are eligible for a catch-up 401(k) contribution. Please enter a number between 0 and 24,500.",3);
event.rc=false;
}
// Checkbox is unchecked
else if(v1 < 1){
var v2 = +event.value;if (v2 > 18500) {
app.alert("Please enter a number between 0 and 18,500.",3);
event.rc=false;
}
}
}
Any help appreciated!
Is this a validation script on the field where the value is being entered? It should be.
So, checkbox values are not 0 and 1. The value of a checkbox is either the export value or "Off"
Event.value can be used by itself, there is no reason to assign it to V2.
...var v1 = getField("401k50").value;
event.rc = true;
if(v1 == "Yes")
{
if(event.value >24500)
{
app.alert("Since you are over 50 you are eligible for a catch-up 401(k) contribution. Please enter a number between 0 and 24,500.",3);
Copy link to clipboard
Copied
Is this a validation script on the field where the value is being entered? It should be.
So, checkbox values are not 0 and 1. The value of a checkbox is either the export value or "Off"
Event.value can be used by itself, there is no reason to assign it to V2.
var v1 = getField("401k50").value;
event.rc = true;
if(v1 == "Yes")
{
if(event.value >24500)
{
app.alert("Since you are over 50 you are eligible for a catch-up 401(k) contribution. Please enter a number between 0 and 24,500.",3);
event.rc = false;
}
}
else
{
if(event.value >18500)
{
app.alert("Please enter a number between 0 and 18,500.",3);
event.rc = false;
}
}
Copy link to clipboard
Copied
Thom,
Thanks for the quick response! Yes, this is validation script. Your script works perfect!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now