Home > Back-end >  How can i fix my input value into december 2022?
How can i fix my input value into december 2022?

Time:01-11

In my project, I need to make a default month and year which the user can't change. He should change only the date in December months. How can I do it?

<input id="input_date" type="date" maxlength="2" min="1" max="31">

CodePudding user response:

min and max should be dates, not numbers. maxlength="2" is not appropriate, since dates have 10 characters.

<input id="input_date" type="date" min="2022-12-01" max="2022-12-31">

Or you could use type="number" if you just want the day of the month.

<input id="input_date" type="number" maxlength="2" min="1" max="31">

  • Related