I am trying to find a way to be able to eliminate the value of day in a date type input, that is, the common thing is that it comes out '09/08/2019'
, I don't know if there is a way so that it is only month and year ( '08/2019'
).
<form action="" method="POST" class="form-row mb-4">
<div class="col">
<label for="fecha">Primera fecha</label>
<input type="date" name="fecha" id="fecha" class="form-control" value="2019-08-09">
</div>
</form>
Option 1: You can use
<input type="month">
:Although a problem may be that it is not supported in some browsers (such as Firefox and Explorer).
For more information you can review the documentation .
Option 2: The option with datepicker could be as follows:
I clarify that the code is not mine, it is from Ben Koehler's answer on Stack Overflow in English jQuery UI DatePicker to show month year only
To change the format of the date you can change the line
dateFormat: 'formato',
and put the format you are looking for (for example'mm-yy'
for'01-2019'
).As it is in English you can try to change it to Spanish as indicated in the answer in DatePicker in Spanish
I hope it helps you, greetings.