Display a Default Text in a Date Field

New Here ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

I would like my field to display the text "enter date" when nothing is displayed. When a user enters a date then the field will verify it is in the following format mm/dd/yyyy. So if the user enters 6/2 then I would like the field to auto format to 06/02/2022.

 

I understand this could be accomplished using the Format option, but if a date format is set then I cannot set a Default Value option.

 

In a different field, I have the following Custom Format Script for a number field. Is there a way I can make this work for my date field.

if (!event.value) {
event.value = "10xxx";
event.target.display = display.noPrint;
} else {
event.target.display = display.visible;
}

 

I am okay with a user typing in a date as 6/2 or 6/2/22 or 6/2/2022, but the end result should be a format as mm/dd/yyyy.

TOPICS
JavaScript , PDF forms

Views

22

Likes

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
Adobe Community Professional ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

LATEST

- You can't use a non-Date string if you've set the field's value to Date. Place that text as the field's tooltip, instead.

- That will happen automatically, if you set the Date format to "mm/dd/yyyyy". Entering "6/2" will cause it to appear as "06/02/2022" when you exit the field. Of course, that doesn't change the field's actual value so it's a dangerous thing to do, because if you export the values you will still get "6/2" in the output, and won't know (for sure) what year was meant.

Likes

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