yes, the keyCode for Chinese is between 0x4e00 (19968) and 0x9fa5 (40869):
if (/[\u4e00-\u9fa5]/.test(String.fromCharCode(event.keyCode)))
{
alert("Chinese");
}
if (/[\u4e00-\u9fa5]/.test(String.fromCharCode(event.keyCode)))
{
alert("Chinese");
}
解决方案 »
- 文件上传问题。
- radupload ajax callback error.source url returned error:503
- 求教一个关于把json数据从后台传到前台的问题。要传输的数据是html格式
- 大侠们帮帮我,有个关于google地图的问题
- 用session怎么无法传值啊?
- asp.net初级问题
- 50分 如何写一个基于Http的 用户协议
- 函数不吃变量,请问是怎么回事?
- 有关于建立群组的问题
- 如何在TreeView1里添加CheckBoxList1?
- 记录集绑定DataGrid,隐藏某一列不显示在DataGrid!
- 我在用datagrid显示数据时,能否采用控件(单选钮、复选框)?
<input onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
2.只能输入数字的:
<input onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
3.只能输入全角的:
<input onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))">
4.只能输入汉字的:
<input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
{
if(char.IsNumber(e.KeyChar))//数字
//char.IsDigit(e.KeyChar)带小数点的
//char.IsLetter 字母
{
//your code;
}
}
/*判断当前字符是英文字符还是中文字符*/
function ifWesternChr(chrInput)
{
var chrInput_e;
chrInput_e=escape(chrInput);
if(chrInput_e.length==(chrInput.length)*6 || chrInput==‘\r’ || chrInput==‘\n’) return false; /*只有非普通ASCII字符经过escape()函数编码之后的长度才会等于原长度的6倍,所以用这种方法可以避开内码直接判断当前字符是否为中文。*/
else return true;
}
</script>
用这个函数判断