带有不允许用户输入的文本输入的 jQuery Datepicker [英] jQuery Datepicker with text input that doesn't allow user input

查看:28
本文介绍了带有不允许用户输入的文本输入的 jQuery Datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 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
日期选择器 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆