Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type date - input using only calendar picker HTML5

Tags:

html

Is there any way not to allow to edit date manually? I mean that I would like to force user to pick date using only calendar.

Having

<input type="date"   value="yyyy-mm-dd" class="input-medium search-query">

user can type in something into input form. I have tried to do this way:

<input type="date"   value="yyyy-mm-dd" class="input-medium search-query" disabled>

but it frozen the whole form.

Any hints? Or maybe is there any fast way to prevent user to break date format? (Because I use bootstrap I would not prefer to use jquery)

like image 847
JosephConrad Avatar asked Sep 15 '25 03:09

JosephConrad


1 Answers

You could return false when the user presses a key, if your prepared to throw a bit of JS in there:

<input type="date"   value="yyyy-mm-dd" class="input-medium search-query" onkeypress="return false">

Here's a jsFiddle

like image 64
George Avatar answered Sep 16 '25 18:09

George