zoukankan      html  css  js  c++  java
  • 有用的JS判断

    function OrtTrimString (strVal)
    {
        var reVal;
        var strTmp;
        strTmp = strVal + "";
        if (strTmp.length == 0)
            return (strTmp);
        reVal = /^(\s| )*/;
        strTmp = strTmp.replace (reVal, '');
        reVal = /(\s| )*$/;
        return (strTmp.replace (reVal, ''));
    }

    -------------------------------

    function OrtHtmlFormat (strVal)
    {
        var reVal;
        var strTmp;
        reVal = /</g;
        strTmp = strVal.replace (reVal, "&lt;");
        reVal = />/g;
        strTmp = strTmp.replace (reVal, "&gt;");
        reVal = /"/g;
        strTmp = strTmp.replace (reVal, "&quot;");
        return (strTmp);
    }

    -------------------------------

    function OrtUrlStringFormat (strVal)
    {
        var reVal;
        var strTmp;
        reVal = /%/g;
        strTmp = strVal.replace (reVal, "%25");
        reVal = /&/g;
        strTmp = strTmp.replace (reVal, "%26");
        reVal = /#/g;
        strTmp = strTmp.replace (reVal, "%23");
        reVal = /\+/g;
        strTmp = strTmp.replace (reVal, "%2b");
        return (strTmp);
    }

    -------------------------------

    function OrtHtmlLine (strVal)
    {
        var reVal;
        var strTmp;
        reVal = /\r/g;
        strTmp = strVal.replace (reVal, "<br>");
        return (strTmp);
    }

    -------------------------------

    function OrtHtmlFormatLine (strVal)
    {
        return (OrtHtmlLine (OrtHtmlFormat (strVal)));
    }

    -------------------------------

    function OrtHtmlSingleQuote (strVal)
    {
        var reVal;
        var strTmp;
        reVal = /'/g;
        strTmp = strVal.replace (reVal, "\\'");
        return (strTmp);
    }

    -------------------------------

    function OrtHtmlDoubleQuote (strVal)
    {
        var reVal;
        var strTmp;
        reVal = /"/g;
        strTmp = strVal.replace (reVal, '\\"');
        return (strTmp);
    }

    -------------------------------

    function OrtHtmlQuote (strVal)
    {
        return (OrtHtmlDoubleQuote (OrtHtmlSingleQuote (strVal)));
    }

    -------------------------------

    function OrtGetGBStrLength (strVal)
    {
        var nLen;
        var i;
        nLen = 0;
        for (i = 0; i < strVal.length; i ++)
        {
            if (strVal.charCodeAt (i) <= 255)
                nLen ++;
            else
                nLen += 2;
        }
        return (nLen);
    }

    -------------------------------

    function OrtCheckNumber (strVal)
    {
        var gar;
        var tmp;
        strVal = OrtTrimString (strVal);
        if (strVal.length == "")
            return (false);
        reVal = /^[\-\+]?([0-9]\d*|0|[1-9]\d{0,2}(,\d{3})*)(\.\d+)?$/;
        if (reVal.test (strVal))
        {
            gar = strVal + '.';
            tmp = gar.split ('.');
            if (tmp[0].length > 15)
                return (false);
            else
                return (true);
        }
        return (false);
    }

  • 相关阅读:
    str_pad 和 filter_var
    phpstorm主题下载地址
    php二维数组的排序
    wx.request出现400 bad request的问题
    php里的闭包函数
    关于宝塔下的项目中的php不能访问的问题
    字体大小适配宽度
    递归复制&查看文件夹下的指定后缀的文件
    find_in_set
    给动态ajax添加的元素添加click事件
  • 原文地址:https://www.cnblogs.com/sishierfei/p/1610542.html
Copyright © 2011-2022 走看看