JavaScript determines the regular of Chinese
JS Check whether it is all Chinese
<ptml xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "en" lang= "en" dir= "ltr" > <pead profile= "http://" www.w3.org/2000/08/w3c-synd/# "> <meta http-equiv=" content-type "content=" text/html; charset=gb2312 "/> <title> Chinese JS test </title> <script> function Ischn (str) {var reg =/^[\u4e00-\u9fa5] +$/; if (!reg.test (str)) {alert ("not Chinese"); return false; Alert ("Chinese"); return true; } </script> </pead> <body onload=ischn ("People") > </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
JS Determines whether the input character is Chinese characters
Copy Code code as follows:
function Ischina (s)//judge whether the character is Chinese
{
var patrn=/[\u4e00-\u9fa5]| [\ufe30-\uffa0]/gi;
if (!patrn.exec (s))
{
return false;
}else{
return true;
}
}