How to Programmatically Set a Date in a Date Picker that Blocks Input and Paste Actions?

I’m trying to automate setting a date in an HTML date picker input field using Puppeteer, but I’ve encountered a problem: the date picker does not allow me to type in special characters, nor does it allow me to paste a date directly into the field.

Here’s the structure of the date picker input field:

<div class="input-group decade_date">
  <input type="text" name="passport_issue_date" 
         class="decade form-control form-control valid" 
         onpaste="return false;" 
         required="" 
         data-toggle="tooltip" 
         id="id_passport_issue_date" 
         tabindex="22" 
         aria-required="true" 
         aria-invalid="false">
</div>

I’ve tried several approaches:

Setting the value attribute directly via JavaScript.
Using Puppeteer to type the date, character by character.
Dispatching custom events to simulate user input.
None of these approaches reflect any change in the input field, likely due to internal validation or JavaScript in the date picker library itself (it appears to be using datepicker2).

My Question:
How can I programmatically set a date in this date picker input field? Is there a workaround in Puppeteer to simulate date selection or bypass these restrictions?

Any insights or suggestions on how to overcome this issue would be greatly appreciated. Thanks in advance!

What did you try and what were you expecting?

I tried several methods to set the date programmatically:

Setting the value attribute directly: I used JavaScript in Puppeteer to set input.value = ‘2024/10/30’, expecting this to update the field with the correct date. However, the input didn’t change visibly on the page, likely because of restrictions in the date picker library.

Typing each character with Puppeteer’s page.type method: I attempted to type each character individually in the date format expected by the input. I anticipated this would mimic real user input, but no date appeared in the field. It seems the input is actively blocking non-numeric characters and possibly even keyboard events from automation tools.

Dispatching custom events: I dispatched input and change events after setting the value in JavaScript, expecting these events to trigger any attached listeners and update the date field. Unfortunately, the date picker did not respond to these events, suggesting it requires specific user actions.

Expectation:
My goal was to automate the date input process as if a user selected a date manually. Ideally, I’d like a solution that bypasses any library restrictions or triggers the date picker’s own event listeners to accept the date input.

Question:
Are there any workarounds that might trigger a proper date selection in date picker libraries like datepicker2?