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

Formatting javascript in Adobe....

Participant ,
Nov 09, 2024 Nov 09, 2024

Good afternoon Community,

 

Hope all is enjoying your weekend.  I have a question on formatting a field in Adobe Acrobat.  I would like to have the following result when someone keys in the information in a particular field.  I've been trying to come up with a Custom Keystroke Script in the formatting section of Adobe.  The Arbitrary Mask is not working.  I would like to limit what someone can key into the field to:  All alphabet letters (small cap and cap), numbers 0-9 and i would like to allow them to put in a hyphen "-".  No spaces.  No characters etc.  I've come up with the first part below and this works for all small cap alphabet letters.  I have no idea to include the rest.  Anyone have any ideas?  Thank you in advance for any input.

 

event.rc=/^[a-z]*$/.test
(event.change);

TOPICS
How to , JavaScript , Modern Acrobat , PDF forms
761
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 09, 2024 Nov 09, 2024

try this:

 

event.rc=/^[\w\-]*$/.test(event.change);

 

Look at this article:

https://www.pdfscripting.com/public/Pattern-Matching-with-Regular-Expressions.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Nov 09, 2024 Nov 09, 2024

try this:

 

event.rc=/^[\w\-]*$/.test(event.change);

 

Look at this article:

https://www.pdfscripting.com/public/Pattern-Matching-with-Regular-Expressions.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Participant ,
Nov 09, 2024 Nov 09, 2024

Please disregard my question.  I am good!

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 ,
Nov 09, 2024 Nov 09, 2024

Interesting, cause I just provided the correct answer. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Participant ,
Nov 09, 2024 Nov 09, 2024
LATEST

You did provide the correct answer.  I tested it to be certain.  It was better than what i came up with.  THANK YOU!

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