hyljava

文本框中只能是数字输入或者是字母输入

<script type="text/javascript">
function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return  numcheck.test(keychar);
}
</script>
<form>
Type some text (numbers not allowed):
<input type="text" onkeypress="return noNumbers(event)" />
</form>

posted on 2013-04-13 10:47 何云隆 阅读(1089) 评论(0)  编辑  收藏 所属分类: JS


只有注册用户登录后才能发表评论。


网站导航: