function onlychinese()
{
if ((window.event.keyCode >=32) && (window.event.keyCode <= 126))
{
window.event.keyCode = 0 ;
}
}
<P>
<INPUT type=text onkeypress="onlychinese()">
<INPUT type="button" value="只能输入中文" name="but1" onclick="javascript:ALERT('谢谢您的访问!')">
</P>