【发布时间】:2019-03-22 21:58:47
【问题描述】:
我想允许除数字之外的所有字符。我在jquery下面写了。
$(".no-numbers").keypress(function(e){
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57))
{
swal({
title: "",
text: "Numbers are not allowed"
});
return false;
}
else
{
return true;
}
});
上面的代码不接受任何东西...请帮忙!!!
【问题讨论】:
-
为什么不使用正则表达式只允许字符?
标签: javascript jquery