【发布时间】:2014-09-13 03:13:45
【问题描述】:
我已从输入 type="number" 中隐藏了旋转框箭头,但数量限制已不起作用。因此,数字框现在接受字母数字字符。
当我能够隐藏微调器箭头时,我使用了此代码:
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}
嗨@BenM!感谢您编辑我的问题。现在,感谢使用 javascript @FakeRainBrigand 的想法,但它对我不起作用。
这对我有用。我正在使用 MVC 和 Razor
` 功能按键(e){ var unicode = e.keyCode ? e.keyCode : e.charCode
if (unicode == 8) {
return;
};
if (unicode == 37 || unicode == 39 || unicode == 38 || unicode == 40 || unicode == 27) {
return;
}
else {
};
if (unicode == 13) {
e.preventDefault();
};
if ($.isNumeric(String.fromCharCode(unicode)) == false) {
e.preventDefault();
};
}
`
【问题讨论】:
-
我在 MVC masterpage
@RenderSection("NumValidation", required: false)中使用了 Razor -
我把这些小码放在输入元素上:onkeypress="keeypress(event)" onchange="keeypress(event)"
标签: css html jquery-mobile