我有一个javascript函数让用户只输入数字。我需要这个功能让我输入“,”和“;”。我该怎么做呢?在我的功能下。只有数字功能
function SomenteNumero(e){
var tecla=(window.event)?event.keyCode:e.which;
if((tecla>47 && tecla<58)) return true;
else{
if (tecla==8 || tecla==0) return true;
else return false;
}
}
谢谢。
你需要把它映射到正确的ASCII字符。请参阅:http://www.asciitable.com/ –
这是我见过的第三篇文章,通过* ascii * char-code进行过滤 - 这是一个糟糕的主意!你从哪里得到这些例子? – Emissary