Skip to main content
Participant
June 2, 2022
Question

Display a Default Text in a Date Field

  • June 2, 2022
  • 1 reply
  • 1399 views

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.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
June 2, 2022

- 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.