Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make data input readonly, but showing calendar?

I can't find any solution for this anywhere. I would like to allow user to see calendar when clicking on my input, but when user will try to change the value, it shouldn't change (or immediately change back for value, what was at the beggining).

Readonly attribute removes calendar, so I was trying to do it different ways like use onchange/onclick functions to restore my value after event, but the value was changing anyway.

So for now my input looks like this:

<input class='test' type='date' value='2020-06-04' onkeydown='return false' >

So at least user can't change value of my input using keyboard. Could you help me?

like image 409
Kida Avatar asked Oct 28 '25 02:10

Kida


1 Answers

You might try to set a time limit

<html>
<body>
<input type="date" value="2020-06-04">
<input type="date" value="2020-06-04" min="2020-06-04" max="2020-06-04">

</body>
</html>
like image 194
Spirytus Rektyfikowany Avatar answered Oct 30 '25 17:10

Spirytus Rektyfikowany