can only enter Chinese
The code is as follows |
Copy Code |
<input onkeyup= "Value=value.replace (/[^/u4e00-/u9fa5]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^/u4e00-/u9fa5]/g, ') "id=" Text4 "name=" TEXT4 "> |
Can only enter Chinese ================//
The code is as follows |
Copy Code |
if (type== "R_china") { if (Value.search (/^[/u4e00-/u9fa5]+$/) ==-1) { Alert (message+ "!/n"); Judge cannot be empty Name.focus (); Name.select (); return false; } } |
The code is as follows |
Copy Code |
if (/[^/x00-/xff]/g.test (s)) alert ("contains Chinese characters"); else alert ("All characters");
|
3. How to judge whether to contain Chinese characters
---------------------------------------
The code is as follows |
Copy Code |
if (Escape (str). IndexOf ("%u")!=-1) alert ("contains Chinese characters"); else alert ("All characters"); |
A function that determines whether the input is Chinese
---------------------------------------
The code is as follows |
Copy Code |
function Ischinese (s) { var ret=true; for (Var i=0;i<s.length;i++) Ret=ret && (S.charcodeat (i) >=10000); return ret; } |
Chinese value detection
code is as follows |
copy code |
function Ischinese (name)//{ if (name.length = 0) return false; for (i = 0; i < name.length. i++) { if (name.charcodeat (i) > 128) return true; } return false; } |