Skip to content

Using custom JS to set a date is not working as expected #103

@RichardWoj

Description

@RichardWoj

Describe the problem
I need to set an "issuance date" to today's date as soon as the user has filled an amount field for an invoice.
I do so with a javascript:
const issuanceDateInput = container.querySelector('.issuance-date-input input[type="text"]');
amountInput.addEventListener('change', () => {
if (amountInput.value !== "") {
issuanceDateInput.value = formatDate(new Date());
issuanceDateHiddenInput.value = formatDate(new Date());

The calculated value is displayed on the browser but the value is not in the post message sent to the server
Do I have to trigger some event?

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
I am expecting the value displayed by the browser to be part of the post message sent to the server

Console errors

  • No error on django console.
  • No error on JavaScript console.

Paste-bin
The page is showing up but the date-picker calendar is not. The paste-bin link
of the HTML source of the page is http://...

Setup Information (please complete the following information):

  • OS: [e.g. Windows 10] Windows
  • Browser [e.g. chrome, safari] Edge
  • Browser version [e.g. 22]
  • Python version [e.g. 3.7] 3.11.3
  • Django version [e.g. 2.1]
  • Bootstrap version [e.g. 3/4] 5
  • jQuery version [e.g. 1.7.1]

[x] I have followed the configuration instructions and checked out the
common error troubleshooting page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions