HTML 5输入类型='日期'禁用键盘输入

编程入门 行业动态 更新时间:2024-10-28 16:26:32
本文介绍了HTML 5输入类型='日期'禁用键盘输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Chrome Packaged应用程序,因此我的代码只能在Chrome中使用。

我有以下输入

< input type =date/>

jsfiddle/jhbo4q2k/

在Chrome上,这会自动添加DatePicker。我只想保留这个Datepicker并通过键盘禁用输入。

这可能吗?

编辑:

接受的答案有效。请谨慎对待

https:/ /developer.chrome/extensions/tut_migration_to_manifest_v2#inline_scripts

您无法在打包的应用程序中使用内联脚本。

<您可以使用 onkeydown 并阻止用户输入值。

< input type =dateonkeydown =return false/>

I am working on a Chrome Packaged App so my code should only work in Chrome.

I have the following input

<input type="date" />

jsfiddle/jhbo4q2k/

On Chrome this automatically adds a DatePicker. I would like to only keep this Datepicker and disable the input by keyboard.

Is this possible?

EDIT:

The accepted answer works. Just be wary of this

developer.chrome/extensions/tut_migration_to_manifest_v2#inline_scripts

You cant use inline scripts in a packaged app.

解决方案

You can use onkeydown and prevent user from entering the value.

<input type="date" onkeydown="return false" />

更多推荐

HTML 5输入类型='日期'禁用键盘输入

本文发布于:2023-10-12 00:56:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483318.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:键盘输入   日期   类型   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!