Prevent users from manually entering dates in input boxen
I am using the jQuery datepick plugin on two input boxes, and would like to p开发者_StackOverflow中文版revent 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?
just add readonly
attributes to those input fields, that will prevent direct entry
Set the "readonly" value on the input.
<input type='text' id='foo' readonly='readonly'>
<input type="text" readonly/>
should do it.
精彩评论