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

Text field for numerals or letters only

New Here ,
May 30, 2018 May 30, 2018

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
2.8K
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 ,
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));

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 ,
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));

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

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?

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

 

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

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

How do I apply a custom keystroke script?

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

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.

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

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!)

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

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

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

YOU ARE A CHAMPION! THANK YOU!

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

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