Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable input, allow click textbox

I'm building a .net web app using Bootstrap styling. I have a datepicker equipped textbox scenario where I would like to avoid the hassle of date string validation. I'm thinking I can simply check for empty string values (no input) as the only necessary validation and disable keyboard input. This way the only input possible is through the datepicker.

My only problem is that the applying the disabled attribute to the datepicker box disables clicking, and the datepicker is shown via the on click for the textbox.

Thus my question is this: how can I disable input for a textbox while still allowing clicking?

like image 206
Freestyle076 Avatar asked Aug 22 '14 21:08

Freestyle076


1 Answers

You can use the readonly attribute instead of disabled.

While disabled elements do not respond to events (such as click or hover), readonly elements behave just like regular elements, although they are not editable. Disabled elements are also not sent on form submits.

JSFiddle

like image 195
rla4 Avatar answered Oct 13 '22 03:10

rla4