开发者

Prevent users from manually entering dates in input boxen

开发者 https://www.devze.com 2023-02-06 16:18 出处:网络
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 tha

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消