gpt4 book ai didi

javascript - 使部分输入值只读

转载 作者:行者123 更新时间:2023-11-28 13:52:42 25 4
gpt4 key购买 nike

如果我的输入的值是日期

03/22/2012

并且我希望数字可编辑,但 / 不可编辑,我可以将 input 的该部分设置为只读吗?

我希望能够在没有插件的情况下完成此任务。

最佳答案

我可能会做这样的事情,仅使用 CSS:

div#dateInput{
border:1px solid #999;
width:100px;
margin:1em;
}

div#dateInput input{
border:0;
width:20px;
outline:0;
}

div#dateInput input:nth-last-child(1){
border:0;
width:35px;
outline:0;
}​

HTML

<div id="dateInput">
<input type="text" /> /
<input type="text" /> /
<input type="text" />
</div>​

示例: http://jsfiddle.net/Qy6BG/

基本上,我从三个输入字段中删除边框和轮廓,并将这些字段“隐藏”在一个div中,我将其设置为看起来像一个输入

关于javascript - 使部分输入值只读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9918344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com