Pontus Svedberg
Pontus Svedberg

Reputation: 305

HTML how to disable select in text input field

I have a text input with a jQuery datepicker to choose dates, and I don't want it to be a possibility to select the text inside of it if someone were to double click the box or so, how can I disable this?

unselectable="on" 

&

user-select: none;

did not work for me, is there another way?

Upvotes: 0

Views: 2703

Answers (2)

this solution should work for you:

<input type="text" readonly="readonly">

Upvotes: 4

Mithilesh Gupta
Mithilesh Gupta

Reputation: 2930

use a span/div as a parent of the input control and on click of this element-show the datepicker

use disabled property on the input control:

<input type="text" disabled>

Upvotes: 0

Related Questions