Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can change the border properties of a checkbox using a script

Community Beginner ,
Jul 02, 2025 Jul 02, 2025

I want to write a script that changes the line style of certain checkboxes (i.e. "solid", "dashed") and also potentially change the border color to "none" in order to remove the border.

 

More specifically I have a bunch of checkboxes with names ending in a number. When a textbox is updated with a number I want all checkboxes up to that number to change to lineStyle Solid.

TOPICS
Edit and convert PDFs , JavaScript , PDF , PDF forms
96
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 03, 2025 Jul 03, 2025

To change the border color of a field use the strokeColor property; To change the line style of a field use the borderStyle property; To change the line width of a field (which is the best way to make it have no border at all) use the lineWidth property.

 

To edit multiple fields up to a number you can use something like this:

var maxFields = 10;

var n = Number(this.getField("Text1").valueAsString);

for (var i=1; i<=maxFields; i++) this.getField("Checkbox"+i).strokeColor = (i<=n) ? color.red : color.black;

 

This will change the border color of all fields from 1 to N as red, and all the others as black.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025
LATEST

More specifically I have a bunch of checkboxes with names ending in a number. When a textbox is updated with a number I want all checkboxes up to that number to change to lineStyle Solid.

 

To change the border style of a group of checkboxes in Adobe Acrobat, you can use the borderStyle property of the field objects. Assuming your checkboxes are named "Check Box1", "Check Box2", ..., and the number of checkboxes to update is entered into a text field, you can use the following script as the custom validation script for that text field:

var n = Number(event.value);

for(var i=1; i<=n; i++){
 this.getField("Check Box"+i).borderStyle = border.s;}

solid - border.s
beveled - border.b
dashed - border.d
inset - border.i
underline - border.u

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025

To change the border color of a field use the strokeColor property; To change the line style of a field use the borderStyle property; To change the line width of a field (which is the best way to make it have no border at all) use the lineWidth property.

 

To edit multiple fields up to a number you can use something like this:

var maxFields = 10;

var n = Number(this.getField("Text1").valueAsString);

for (var i=1; i<=maxFields; i++) this.getField("Checkbox"+i).strokeColor = (i<=n) ? color.red : color.black;

 

This will change the border color of all fields from 1 to N as red, and all the others as black.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025
LATEST

More specifically I have a bunch of checkboxes with names ending in a number. When a textbox is updated with a number I want all checkboxes up to that number to change to lineStyle Solid.

 

To change the border style of a group of checkboxes in Adobe Acrobat, you can use the borderStyle property of the field objects. Assuming your checkboxes are named "Check Box1", "Check Box2", ..., and the number of checkboxes to update is entered into a text field, you can use the following script as the custom validation script for that text field:

var n = Number(event.value);

for(var i=1; i<=n; i++){
 this.getField("Check Box"+i).borderStyle = border.s;}

solid - border.s
beveled - border.b
dashed - border.d
inset - border.i
underline - border.u

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines