isekaijin
isekaijin

Reputation: 19742

Prevent users from manually entering dates in input boxen

I am using the jQuery datepick plugin on two input boxes, and would like to prevent users of my Web site from manually entering dates in those input boxes. How could I do that?

I think I could cancel the onkeydown and onkeypress events, but it doesn't strike me as particularly elegant to do the same thing on two event handlers. Is there any other means to achieve the same thing?

Upvotes: 0

Views: 1856

Answers (3)

John K.
John K.

Reputation: 5474

Set the "readonly" value on the input.

<input type='text' id='foo' readonly='readonly'>

Upvotes: 3

jAndy
jAndy

Reputation: 235972

<input type="text" readonly/>

should do it.

Upvotes: 2

Kris Ivanov
Kris Ivanov

Reputation: 10598

just add readonly attributes to those input fields, that will prevent direct entry

Upvotes: 5

Related Questions