Skip to main content
Participant
May 27, 2020
Answered

First letter capitalization

  • May 27, 2020
  • 2 replies
  • 2868 views

Hi,

I'm very new to Acrobat Pro. Trying to make fillable PDF forms.

I would like to have the first letter in capital ie "john" to be "John" or when they type a city that has more than two words in it ie. San Francisco to get the first letter capitalized.

 

Is there any way when someone types a date 05272020 to add automatically the slashes without typing the slashes?

 

Thank you very much for any help.

This topic has been closed for replies.
Correct answer Tom3670211920ss

I came across this post when looking for the same solution for a user to be able to enter dates with or without slashes in to display as mm/dd/yyyy. I found a solution and figured I'd pass it along to anyone that could use it. Hope this helps someone.

 

First, change the Format to "None".

Now run this custom validation script:

var date = /^\d{2}\d{2}\d{4}?$/;
if (event.value!=""){if (!date.test(event.value)){event.rc = false;app.alert("\"" + event.value + "\" is not a valid entry. Please enter an 8 digit date.");};};
if (/^\d{8}$/.test(event.value)) event.value = event.value.substring(0,2) +"/"+event.value.substring(2,4) +"/"+event.value.substring(4,8)

2 replies

Tom3670211920ssCorrect answer
Participant
April 12, 2024

I came across this post when looking for the same solution for a user to be able to enter dates with or without slashes in to display as mm/dd/yyyy. I found a solution and figured I'd pass it along to anyone that could use it. Hope this helps someone.

 

First, change the Format to "None".

Now run this custom validation script:

var date = /^\d{2}\d{2}\d{4}?$/;
if (event.value!=""){if (!date.test(event.value)){event.rc = false;app.alert("\"" + event.value + "\" is not a valid entry. Please enter an 8 digit date.");};};
if (/^\d{8}$/.test(event.value)) event.value = event.value.substring(0,2) +"/"+event.value.substring(2,4) +"/"+event.value.substring(4,8)

Thom Parker
Community Expert
Community Expert
April 14, 2024

Note to anyone reading this thread. The post above has nothing to do with the thread topic and was marked as the correct answer by the poster. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
May 28, 2020

I would recommend you don't do that. Some names can contain more than one capital letter in a single word and you'll be removing that. Also, some first letters in some names should not be capitalized at all, and you would be doing it incorrectly.

Trust your users to enter their own names correctly.

 

Regarding your second request: You can use the built-in Date format setting "mm/dd/yyyy".

yoyo63Author
Participant
May 30, 2020

Thank you regarding the capitalization of the names. What about city nmaes with two or three words in them ie. San Francisco, South Lake City etc.

 

Sometimes the user enters date in format mmddyyyy without the slashes and they get error message that the date format is incorrect and they need to place the "/" symbol. Is there any way to change the format to mm/dd/yyyy after the user eneters the date as said above. I do have is set to built in Date format as you mentioned.

 

Thank you again for your help and further input.

Thom Parker
Community Expert
Community Expert
May 31, 2020
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often