具有不允许用户输入的文本输入的jQuery Datepicker [英] jQuery Datepicker with text input that doesn't allow user input
问题描述
如何使用jQuery Datepicker与文本框输入:
How do I use the jQuery Datepicker with a textbox input:
$("#my_txtbox").datepicker({
// options
});
不允许用户在文本框中输入随机文本。
当文本框获取焦点或用户点击它时,我想要弹出Datepicker,但是我希望文本框忽略使用键盘的任何用户输入(复制和粘贴或任何其他)。我想从Datepicker日历中专门填写文本框。
that doesn't allow the user to input random text in the textbox. I want the Datepicker to pop up when the textbox gains focus or the user clicks on it, but I want the textbox to ignore any user input using the keyboard (copy & paste, or any other). I want to fill the textbox exclusively from the Datepicker calendar.
这是可能吗?
jQuery 1.2.6
Datepicker 1.5.2
jQuery 1.2.6
Datepicker 1.5.2
推荐答案
你应该可以使用 readonly 属性,jQuery仍然可以编辑其内容。
You should be able to use the readonly attribute on the text input, and jQuery will still be able to edit its contents.
<input type='text' id='foo' readonly='true'>
这篇关于具有不允许用户输入的文本输入的jQuery Datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!