我有点好奇,我已经创建了一个响应式网站而且我使用了2个脚本来禁用输入字段中的数字键;第一个不允许输入数字,第二个,出现一条警告消息,警告您只能键入字母字符,我想了解为什么智能手机只能在Firefox上工作,而在PC上完美工作: 此脚本禁用数字键:
enter code here
function Check(e) {
var keyCode = (e.keyCode ? e.keyCode : e.which);
if (keyCode > 47 && keyCode < 58) {
e.preventDefault();
}
}
这会显示消息:
$(document).ready(function(){
$(".inputTextBox").keypress(function(event){
var inputValue = event.which;
// allow letters and whitespaces only.
if(!(inputValue >= 65 && inputValue <= 123) && (inputValue != 32 && inputValue != 0)) {
event.preventDefault();
document.getElementById('warning07').style.display='block';
document.getElementById('07').innerHTML = "Inserire solo lettere!";
}
console.log(inputValue);
});
});
你可以解释一下吗?提前谢谢。