只让输入数字的输入框
<body>
<script>
function JHshNumberText()
{
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57))
|| (window.event.keyCode == 13) || (window.event.keyCode == 46)
|| (window.event.keyCode == 45)))
{
window.event.keyCode = 0 ;
}
}
</s cript>
<form name=frm>
<input type=text name=test value="" onKeypress="JHshNumberText()">
<input type=button name=submit value=submit>
</form>
</body>
只能输入汉字的输入框
<SCRIPT>
function onlychinese()
{
if ((window.event.keyCode >=32) && (window.event.keyCode <= 126))
{
window.event.keyCode = 0 ;
}
}
</SCRIPT>
<FORM name=frm >只能输入汉字的输入框
<P><INPUT onkeypress="onlychinese() " name=test> <INPUT type=button value=只能输入中文 name=submit onclick="javascript:ALERT('谢谢您的访问!')"> </P></FORM>
posted on 2005-06-10 14:17
楚客 阅读(1155)
评论(1) 编辑 收藏 所属分类:
HTML