'How to reset input date value when the form is prefilled

I have already checked this: How do you programmatically clear HTML5 date fields?

In my case, my form is pre-filled by existing value, and I want user change the date by null in database via the form updatting. Here are what I tried:

$('input[name=theDate]').val('');    //does not work.

$('input[name=theDate]').removeAttr('value'); //does not work too

In the first case I get jj/mm/aaaa in the input but in dom I always have the existing value for this input

<input type="date" name="theDate" value="2022-04-03">

In the second case, I get jj/mm/aaaa and attribute value does not exist anymore, but the server is getting the existing value like the attribute exists but is just hide.

<input type="date" name="theDate">

How to deal with this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source