zoukankan      html  css  js  c++  java
  • 网页中常用的js特效

    1.剩余文字数提醒

     <script type="text/javascript">
        //文本框剩余字数提示(字符大小)
    function textLimitCheckSj(thisArea, maxLength, SpanId) {
        var str = thisArea.value;
        if (getChrLen(str, maxLength) > maxLength * 2) {
            thisArea.value = str.substring(0, x-1);
        }
        else {
            var varss = '(剩余字数:' + Math.floor((maxLength * 2 - getChrLen(str, maxLength)) / 2) + ')';
            document.getElementById(SpanId).innerHTML = varss;
        }
    }
    function getChrLen(str, maxLength) {
        var realLength = 0, len = str.length, charCode = -1;
        x = 0;
        for (; (x < len) && (realLength <=maxLength * 2); x++) {
            charCode = str.charCodeAt(x);
            if (charCode >= 0 && charCode <= 128)
                realLength += 1;
            else
                realLength += 2;
        }
        return realLength;
    }

    </script>
    <asp:TextBox ID="txtOwner_Name" runat="server" Width="200px" BackColor="LightYellow"
                            onkeyup="textLimitCheckSj(this,50,'spOwner_Name')"></asp:TextBox>
                            <span id="spOwner_Name"
                                style="color: #808080"><em>(50字以内)</em></span>

  • 相关阅读:
    clone对象
    Windows下swoole扩展的编译安装部署
    PHP备忘录
    Linux文档的压缩与打包
    Linux系统启动过程
    Linux虚拟机安装
    MongoDB自动增长
    MongoDB固定集合(Capped Collections)
    Activating Google Cloud Storage
    Downloading the Google Cloud Storage Client Library
  • 原文地址:https://www.cnblogs.com/licuihua/p/3385432.html
Copyright © 2011-2022 走看看