楼上正解,字符的ASCII码值>255,就应该是中文

解决方案 »

  1.   

    //这样行吗
    function checkchinese(theelement)
    {//如果含有中文字符返回 true
       text="abcdefghijklmnopqrstuvwxyz1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ,/()!@$%&\#*~.;'_-<table>";
       for(i=0;i<=theelement.length-1;i++)
       {
          char1=theelement.charAt(i);
          index=text.indexOf(char1);
          if(index==-1)
          {
             return true;//有中文
          }  
         //没有中文
       }
       return false;
    }
      

  2.   

    js
    <script>
    /*** 检查是否包含汉字 ***/
    String.prototype.isInChinese = function() {
      return (this.length != this.replace(/[^\x00-\xff]/g,"**").length);
    }s = "adsfasd你好asdfasdf";
    if(s.isInChinese())
      alert("有汉字");
    </script>php
    <?php
    $s = "adsfasd你好asdfasdf";
    if(preg_match("/[\x80-\xff]./",$s))
      echo "有汉字";
    ?>
      

  3.   

    <?php
    $s = "adsfasd你好asdfasdf";
    if(preg_match("/[\x80-\xff]./",$s))
      echo "有汉字";
    ?>
    此法最好