<script language="javascript">
    <!--
        function MaxLength(field,maxlimit)
        {
             var j = field.value.replace(/[^\x00-\xff]/g,"**").length;
             //alert(j);
             var tempString=field.value;
             var tt="";
             if(j > maxlimit)
             {
                 for(var i=0;i<maxlimit;i++)
                 {
                    if(tt.replace(/[^\x00-\xff]/g,"**").length < maxlimit)
                    tt = tempString.substr(0,i+1);
                    else
                    break;
                 }
                 if(tt.replace(/[^\x00-\xff]/g,"**").length > maxlimit)
                 tt=tt.substr(0,tt.length-1);
                 field.value = tt;
               }
               else
               {
                     ;
               }
         }
    -->
</script>  

 <asp:TextBox ID="TextBox1" runat="server" Height="202px" TextMode="MultiLine"  Width="98%"
                            Font-Names="宋体" Font-Size="12pt" onpropertychange="MaxLength(this,1300)"></asp:TextBox>

posted on 2011-05-27 09:13  dinoy  阅读(1530)  评论(0编辑  收藏  举报