Date type for Form Fields (web)

https://www.pdftron.com/documentation/web/guides/forms/date-picker-field/

I am trying to have a date type form field for my pdf, but it seems like i can only set these via UI “Tx”, “Ch”, “Btn”, “Sig”.

Is “Date” type not set by type but by name only? Can i have a custom type as date?

How can i create a UI button for date type on the creating phase and detect it on the signing phrase.

TIA

According to our API: PDFTron WebViewer Class: Field
The supported types that you can pass to Field constructor are: “Tx”, “Ch”, “Btn”, “Sig” (which are short for TextField, ChoiseField, ButtonField and SignatureField), I don’t think you can set the type as “Date” here.

However, when we create a Data picker, we are using “TextField + DatePickerWidgetAnnotation”
So, you can create a date picker using a Text Field, here is a sample code:

document.getElementById('myBtn').addEventListener('click', () => {

    // set flags for multiline and required
    const flags = new WidgetFlags();
    flags.set('Multiline', false);
    flags.set('Required', true);

    // create a form field
    const field = new Annotations.Forms.Field("some text field name", {
      type: 'Tx',
      defaultValue: "2021/09/01",
      flags,
    });

    // create a date picker widget annotation
    const widgetAnnot = new Annotations.DatePickerWidgetAnnotation(field);

    // set position and size
    widgetAnnot.PageNumber = 1;
    widgetAnnot.X = 100;
    widgetAnnot.Y = 100;
    widgetAnnot.Width = 50;
    widgetAnnot.Height = 20;

    //add the form field and widget annotation
    annotManager.addAnnotation(widgetAnnot);
    annotManager.drawAnnotationsFromList([widgetAnnot]);
    annotManager.getFieldManager().addField(field);
  });

Oscar