Copy link to clipboard
Copied
Hi Folks,
We print NCR (carbonless forms) that clients often want numbered. On our Requisition we have two fields, one for the starting number and one for the end number. I don't want to make the two fields required because the forms aren't always numbered, but I do want to require a client to input the last number if they input a start number. Any ideas how to do this? Thank you.
Copy link to clipboard
Copied
If you enter this custom validation script in the first field, a message will popup after they enter a value and then set the focus to the 2nd field (I named it "EndPage" in the script).
if(event.value)
{
app.alert("Please input the ending page number.");
this.getField("EndPage").setFocus();
}
To make the field required if the first field contains a value enter this script as a custom calculation script in the EndPage field:
if(this.getField("StartPage").value)
{event.target.required=true}
else
{event.target.required=false}
Copy link to clipboard
Copied
If you enter this custom validation script in the first field, a message will popup after they enter a value and then set the focus to the 2nd field (I named it "EndPage" in the script).
if(event.value)
{
app.alert("Please input the ending page number.");
this.getField("EndPage").setFocus();
}
To make the field required if the first field contains a value enter this script as a custom calculation script in the EndPage field:
if(this.getField("StartPage").value)
{event.target.required=true}
else
{event.target.required=false}
Copy link to clipboard
Copied
Hello, and thanks for the prompt reply!
I renamed my fields to StartPage and EndPage, but when I enter the script I get a Syntax Error...I've attached the screenshot. ( I have no experience with scripting, btw!)
Copy link to clipboard
Copied
You copied a bunch of text that isn't a part of the code...
Copy link to clipboard
Copied
So I did! I paid closer attention, and the scripts do exactly what I needed!!
Copy link to clipboard
Copied
It's two different scripts for two different fields with "To make the field required if the first field contains a value enter this script as a custom calculation script in the EndPage field:" as my instructions in between.
Copy link to clipboard
Copied
Thanks, yes, I figured it out finally. Thank you for your help, it works perfectly.
Copy link to clipboard
Copied
You can use the following as the custom calculation script of the second field:
event.target.required = (this.getField("StartNumber").valueAsString!="");
Be aware that the required property is only validated when the file is submitted, though, not when it's saved, printed or emailed, or anything like that.
Copy link to clipboard
Copied
Ah, OK, thanks. I need it to be visible always, as we print the Reqs and they travel with he Job bag. And thanks too for the prompt response!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now