Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can i fix my input value into december 2022?

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">

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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">
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading