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

Custom date format on date field

Community Beginner ,
May 12, 2022 May 12, 2022

Hello:

 

I am building a form with Adobe Acrobat Pro DC Version 2022.001.20117.

I need to redestribute a fillable form through internet.

 

I need a date field that must contain (in catalan):

04 de maig de 2022

I have used date custom format like this : dd \de mmmm \de yyyy

"de" must be literal. I use "\" char trying to avoid "d" being conseidered as day.

It doesn't work

Anyone knows how to get it?

 

Thanks in advance.

 

Frank

TOPICS
JavaScript
2.9K
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 12, 2022 May 12, 2022

Use workaround with two fields, lets call them 'field1' and 'field2'.
In field1 you will select date and then hide it to show field2 with desired format, when you click on field2 to change date it will be hidden and focus set to field1.
1. In field1 use format 'dd mmmm yyyy',
as 'On Blur' action use this:

if(event.value){
event.target.display = display.hidden;
this.getField("field2").display = display.visible;}

as 'Validation' script use this:

var str = event.value;
var date = str.split(" ");
if(event.value)
this.getField("field2").value = date[0]+" de "+date[1]+" de "+date[2];
else
this.getField("field2").value = "";

2. in field2 as 'On Focus' action use this:

event.target.display = display.hidden;
this.getField("field1").display = display.visible;
this.getField("field1").setFocus();

Now put fields on top of each other so they are in same place.

Here is sample how it should work:

https://drive.google.com/uc?export=download&id=16ZUdWggM7hwNW4Cf1Xq0RjEoUEoWAOWn 

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 12, 2022 May 12, 2022

Hi,

 

I think you need to double \ the string so it looks like this

dd \\de mmmm \\de yyyy

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 12, 2022 May 12, 2022

Hello:

 

It doesn't work for me.

 

 

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 12, 2022 May 12, 2022

I use dd \de mmmm \de yyyy format. When the control recieves focus the date is being showed like it must be.

18 de mayo de 2022

When the control loses it's focus the value shown changes to:

18 18e mayo 18e 2022

 

 

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 12, 2022 May 12, 2022

Hi,

 

Using the double backslash it works for me, the settings are

BarlaeDC_0-1652350343315.pngexpand image

type in date such as

BarlaeDC_1-1652350374781.pngexpand image

And the date is displayed as

BarlaeDC_2-1652350400030.pngexpand image

 

 

 

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 12, 2022 May 12, 2022

If you type the date directly it works. But if you choose it from pickup calendar it does'nt work. I need users can select date from pickup calendar.

 

 

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 12, 2022 May 12, 2022

Use workaround with two fields, lets call them 'field1' and 'field2'.
In field1 you will select date and then hide it to show field2 with desired format, when you click on field2 to change date it will be hidden and focus set to field1.
1. In field1 use format 'dd mmmm yyyy',
as 'On Blur' action use this:

if(event.value){
event.target.display = display.hidden;
this.getField("field2").display = display.visible;}

as 'Validation' script use this:

var str = event.value;
var date = str.split(" ");
if(event.value)
this.getField("field2").value = date[0]+" de "+date[1]+" de "+date[2];
else
this.getField("field2").value = "";

2. in field2 as 'On Focus' action use this:

event.target.display = display.hidden;
this.getField("field1").display = display.visible;
this.getField("field1").setFocus();

Now put fields on top of each other so they are in same place.

Here is sample how it should work:

https://drive.google.com/uc?export=download&id=16ZUdWggM7hwNW4Cf1Xq0RjEoUEoWAOWn 

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 12, 2022 May 12, 2022

Great solution Nesa.

Thank you for your help.

 

Thank you @BarlaeDC for your help too.

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 31, 2023 May 31, 2023

Muy buena idea, pero funciona una vez. Si lo guardan y lo copian para alguien más o desean cambiar la fecha, ya no podrán volver a seleccionarla del calendario. Alguna solución para esto???

 

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 31, 2023 May 31, 2023

Perdón. Error de configuración. Es una excelente opción y funciona a la perfección. Muchas gracias. @Nesa Nurani 

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 ,
Nov 01, 2023 Nov 01, 2023

This is such an awesome solution! 
Is there a way to add instructional text, i.e., "Enter date here". Once the user enters the date, this instructional text will disappear. I believe this would need to be added to the field2 code???
Thank you in advance!

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 ,
Apr 05, 2024 Apr 05, 2024
LATEST

Hello,

Nesa's answer was very helpful.

I have introduced some imrpovements on her solution that worked better for me. I share them in case they are useful.

1. In field 1, use format 'dd/mm/yyyy'.

  as 'On Blur' action, use:

this.getField("field1").display = display.hidden;
this.getField("field2").display = display.visible;

  as 'Mouse Down' action, use (this shouldn't be necessary, but just to be on the safe side):

var field1 = this.getField("field1");
this.field1.display = display.visible;
this.getField("field2").display = display.hidden;
this.field1.setFocus();

as 'Validation' script, use this:

var field2 = this.getField("field2");
this.field2.value = event.value || "";
this.getField("field1").display = display.hidden;
this.field2.display = display.visible;

2. In field2 use format 'd \\de mmmm \\de yyyy'.

  as 'Mouse Down' action, use:

var field1 = this.getField("field1");
this.field1.display = display.visible;
this.getField("field2").display = display.hidden;
this.field1.setFocus();

It's a bit simpler and reacted better to the events in the tests I did. It also uses as format for the edition the most usual short date format for Catalan.

 

Hope it helps!

 

Juan

 

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