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

Text field for numerals or letters only

New Here ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

Hi.

I'm trying to get certain fields for numbers only and certain others for letters only. When I open Text Field Properties, there is no option for numbers or letters only. Really stuck! (also, don't have a clue where or how to do coding if needed...!)

Thanks!

TOPICS
PDF forms

Views

1.7K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , May 30, 2018 May 30, 2018

This can be done using a custom Keystroke script.

For example, this one will only allow numbers:

event.rc = /^\d*$/.test(AFMergeChange(event));

And this one will only allow letters (both lower and upper case):

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

Votes

Translate

Translate
Community Expert ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

This can be done using a custom Keystroke script.

For example, this one will only allow numbers:

event.rc = /^\d*$/.test(AFMergeChange(event));

And this one will only allow letters (both lower and upper case):

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

Votes

Translate

Translate

Report

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
New Here ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

This is nearly perfect for me.  I would like to use event.rc = /^[a-z]*$/i.test(AFMergeChange(event)); but also allow for a space.  My intent is to use the code in a "City" field.  Some cities, like San Francisco, require a space between two words/letters.  Is this possible?

Votes

Translate

Translate

Report

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 Beginner ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

LATEST

Yes, it’s possible:

 

event.rc = /^[a-z\s]*$/i.test(AFMergeChange(event));

 

 Alternatively, if you want to include hyphens for compound words:

 

event.rc = /^[a-z\s-]*$/i.test(AFMergeChange(event));

 

 For non-English Latin-1 alphabets that use diacritics:

event.rc = /^[a-zÀ-ž\s-]*$/i.test(AFMergeChange(event));

 

Votes

Translate

Translate

Report

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
New Here ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

Thank you, but I'm not sure how to do this.

How do I apply a custom keystroke script?

Votes

Translate

Translate

Report

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 ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

Right-click the field in Form Edit mode, select Properties, Format, Custom and then click on Edit next to Custom Keystroke Script and paste the code into the window that opens.

It's possible that after you do that the selection will revert back to None. That's OK. Just click on Close and it should work.

Votes

Translate

Translate

Report

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
New Here ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

Thank you for your quick reply. Much appreciated.

.... Problem is, when I go into Properties, I only have 4 tabs, (General, Appearance, Position and Options)! (No Format option!)

Votes

Translate

Translate

Report

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 ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

Click on Tools - Prepare Form and then click on "More" at the right side of the window and then on "Revert to Acrobat Form".

Votes

Translate

Translate

Report

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
New Here ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

YOU ARE A CHAMPION! THANK YOU!

Thanks for your patience and quick replies. Have a great day!

Votes

Translate

Translate

Report

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