Verify that it is the most basic and commonly used expression in Chinese:
Matching regular expressions for Chinese characters: [U4E00-U9FA5]
Commentary: Matching Chinese is really a headache, with this expression will be easy to do
Match Double-byte characters (including Chinese characters): [^x00-xff]
Commentary: can be used to compute the length of a string (a double-byte character length meter 2,ascii 1 characters)
function Ischinese (obj,obj_name) {
var reg=/^[u0391-uffe5]+$/;
if (obj.value!= "" &&!reg.test (Obj.value)) {
Alert (obj_name+ ' must enter Chinese!) ');
Obj.value = "";
Obj.focus ();
return false;
}
}
Two bytes in text
Jquery.validator.addmethod ("Byterangelength", function (value, element, param) {
var length = Value.length;
for (var i = 0; i < value.length; i++) {
if (Value.charcodeat (i) > 127) {
length++;
}
}
Only Chinese can be entered with regular expression restrictions:
Onkeyup= "Value=value.replace (/[^u4e00-u9fa5]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^u4e00-u9fa5]/g, ') "