<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 22, comments - 8, trackbacks - 0, articles - 0
       :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

    javascript函數庫

    Posted on 2006-12-29 19:35 路易 閱讀(167) 評論(0)  編輯  收藏 所屬分類: 東方夜譚
    ??1 -------------- ?函數檢索? --------------
    ??2 trim函數:?????????????????????????trim()?lTrim()?rTrim()
    ??3 校驗字符串是否為空:?????????????????checkIsNotEmpty(str)
    ??4 校驗字符串是否為整型:???????????????checkIsInteger(str)
    ??5 校驗整型最小值:????????????????????checkIntegerMinValue(str,val)
    ??6 校驗整型最大值:????????????????????checkIntegerMaxValue(str,val)?
    ??7 校驗整型是否為非負數:???????????????isNotNegativeInteger(str)
    ??8 校驗字符串是否為浮點型:?????????????checkIsDouble(str)?
    ??9 校驗浮點型最小值:??????????????????checkDoubleMinValue(str,val)
    ?10 校驗浮點型最大值:??????????????????checkDoubleMaxValue(str,val)
    ?11 校驗浮點型是否為非負數:?????????????isNotNegativeDouble(str)
    ?12 校驗字符串是否為日期型:?????????????checkIsValidDate(str)
    ?13 校驗兩個日期的先后:????????????????checkDateEarlier(strStart,strEnd)
    ?14 校驗字符串是否為email型:???????????checkEmail(str)
    ?15
    ?16 校驗字符串是否為中文:???????????????checkIsChinese(str)
    ?17 計算字符串的長度,一個漢字兩個字符:???realLength()
    ?18 校驗字符串是否符合自定義正則表達式:???checkMask(str,pat)
    ?19 得到文件的后綴名:???????????????????getFilePostfix(oFile)??
    ?20 -------------- ?函數檢索? --------------
    ?21 */
    ?22
    ?23 /* *
    ?24 *?added?by?LxcJie?2004.6.25
    ?25 *?去除多余空格函數
    ?26 *?trim:去除兩邊空格?lTrim:去除左空格?rTrim:?去除右空格
    ?27 *?用法:
    ?28 *?????var?str?=?"??hello?";
    ?29 *?????str?=?str.trim();
    ?30 */

    ?31 String.prototype.trim? = ? function ()
    ?32 {
    ?33 ???? return ? this .replace( / ( ^ [s] * ) | ([s] * $) / g,? "" );
    ?34 }

    ?35 String.prototype.lTrim? = ? function ()
    ?36 {
    ?37 ???? return ? this .replace( / ( ^ [s] * ) / g,? "" );
    ?38 }

    ?39 String.prototype.rTrim? = ? function ()
    ?40 {
    ?41 ???? return ? this .replace( / ([s] * $) / g,? "" );
    ?42 }

    ?43 /* *********************************?Empty?************************************* */
    ?44 /* *
    ?45 *校驗字符串是否為空
    ?46 *返回值:
    ?47 *如果不為空,定義校驗通過,返回true
    ?48 *如果為空,校驗不通過,返回false???????????????參考提示信息:輸入域不能為空!
    ?49 */

    ?50 function ?checkIsNotEmpty(str)
    ?51 {
    ?52 ???? if (str.trim()? == ? "" )
    ?53 ???????? return ? false ;
    ?54 ???? else
    ?55 ???????? return ? true ;
    ?56 }
    // ~~~
    ?57 /* ---------------------------------?Empty?-------------------------------------- */
    ?58 /* *********************************?Integer?************************************ */
    ?59 /* *
    ?60 *校驗字符串是否為整型
    ?61 *返回值:
    ?62 *如果為空,定義校驗通過,??????返回true
    ?63 *如果字串全部為數字,校驗通過,返回true
    ?64 *如果校驗不通過,??????????????返回false?????參考提示信息:輸入域必須為數字!
    ?65 */

    ?66 function ?checkIsInteger(str)
    ?67 {
    ?68 ???? // 如果為空,則通過校驗
    ?69 ???? if (str? == ? "" )
    ?70 ???????? return ? true ;
    ?71 ???? if ( /^ ( -? )(d + )$ / .test(str))
    ?72 ???????? return ? true ;
    ?73 ???? else
    ?74 ???????? return ? false ;
    ?75 }
    // ~~~
    ?76 /* *
    ?77 *校驗整型最小值
    ?78 *str:要校驗的串。??val:比較的值
    ?79 *
    ?80 *返回值:
    ?81 *如果為空,定義校驗通過,????????????????返回true
    ?82 *如果滿足條件,大于等于給定值,校驗通過,返回true
    ?83 *如果小于給定值,????????????????????????返回false??????????????參考提示信息:輸入域不能小于給定值!
    ?84 */

    ?85 function ?checkIntegerMinValue(str,val)
    ?86 {
    ?87 ???? // 如果為空,則通過校驗
    ?88 ???? if (str? == ? "" )
    ?89 ???????? return ? true ;
    ?90 ???? if ( typeof (val)? != ? " string " )
    ?91 ????????val? = ?val? + ? "" ;
    ?92 ???? if (checkIsInteger(str)? == ? true )
    ?93 ???? {
    ?94 ???????? if (parseInt(str, 10 ) >= parseInt(val, 10 ))
    ?95 ???????????? return ? true ;
    ?96 ???????? else
    ?97 ???????????? return ? false ;
    ?98 ????}

    ?99 ???? else
    100 ???????? return ? false ;
    101 }
    // ~~~
    102 /* *
    103 *校驗整型最大值
    104 *str:要校驗的串。??val:比較的值
    105 *
    106 *返回值:
    107 *如果為空,定義校驗通過,????????????????返回true
    108 *如果滿足條件,小于等于給定值,校驗通過,返回true
    109 *如果大于給定值,????????????????????????返回false???????參考提示信息:輸入值不能大于給定值!
    110 */

    111 function ?checkIntegerMaxValue(str,val)
    112 {
    113 ???? // 如果為空,則通過校驗
    114 ???? if (str? == ? "" )
    115 ???????? return ? true ;
    116 ???? if ( typeof (val)? != ? " string " )
    117 ????????val? = ?val? + ? "" ;
    118 ???? if (checkIsInteger(str)? == ? true )
    119 ???? {
    120 ???????? if (parseInt(str, 10 ) <= parseInt(val, 10 ))
    121 ???????????? return ? true ;
    122 ???????? else
    123 ???????????? return ? false ;
    124 ????}

    125 ???? else
    126 ???????? return ? false ;
    127 }
    // ~~~
    128 /* *
    129 *校驗整型是否為非負數
    130 *str:要校驗的串。
    131 *
    132 *返回值:
    133 *如果為空,定義校驗通過,返回true
    134 *如果非負數,????????????返回true
    135 *如果是負數,????????????返回false???????????????參考提示信息:輸入值不能是負數!
    136 */

    137 function ?isNotNegativeInteger(str)
    138 {
    139 ???? // 如果為空,則通過校驗
    140 ???? if (str? == ? "" )
    141 ???????? return ? true ;
    142 ???? if (checkIsInteger(str)? == ? true )
    143 ???? {
    144 ???????? if (parseInt(str, 10 )? < ? 0 )
    145 ???????????? return ? false ;
    146 ???????? else
    147 ???????????? return ? true ;
    148 ????}

    149 ???? else
    150 ???????? return ? false ;
    151 }
    // ~~~
    152 /* ---------------------------------?Integer?-------------------------------------- */
    153 /* *********************************?Double?*************************************** */
    154 /* *
    155 *校驗字符串是否為浮點型
    156 *返回值:
    157 *如果為空,定義校驗通過,??????返回true
    158 *如果字串為浮點型,校驗通過,??返回true
    159 *如果校驗不通過,??????????????返回false?????參考提示信息:輸入域不是合法的浮點數!
    160 */

    161 function ?checkIsDouble(str)
    162 {
    163 ???? // 如果為空,則通過校驗
    164 ???? if (str? == ? "" )
    165 ???????? return ? true ;
    166 ???? // 如果是整數,則校驗整數的有效性
    167 ???? if (str.indexOf( " . " )? == ? - 1 )
    168 ???? {
    169 ???????? if (checkIsInteger(str)? == ? true )
    170 ???????????? return ? true ;
    171 ???????? else
    172 ???????????? return ? false ;
    173 ????}

    174 ???? else
    175 ???? {
    176 ???????? if ( /^ ( -? )(d + )(. { 1 } )(d + )$ / g.test(str))
    177 ???????????? return ? true ;
    178 ???????? else
    179 ???????????? return ? false ;
    180 ????}

    181 }
    // ~~~
    主站蜘蛛池模板: 美丽的姑娘免费观看在线播放| 国产免费一区二区三区不卡| 在线视频免费观看高清| 亚洲最大视频网站| 91精品成人免费国产片| 亚洲黄色免费电影| 男女免费观看在线爽爽爽视频| 亚洲精品456人成在线| 天天干在线免费视频| 国内成人精品亚洲日本语音| 免费一级毛片在线观看| EEUSS影院WWW在线观看免费| 亚洲精品无码永久在线观看你懂的| a级片免费在线观看| 亚洲男人第一av网站| 中国在线观看免费高清完整版 | 999久久久免费精品国产| 亚洲成av人片在线看片| 国内一级一级毛片a免费| 男人j进女人p免费视频| 亚洲AV综合色区无码一区| 久视频精品免费观看99| 亚洲高清乱码午夜电影网| 国产成人亚洲综合无码| 久久午夜伦鲁片免费无码| 亚洲最大中文字幕无码网站| 亚洲成av人在片观看| 99re6在线视频精品免费下载| 456亚洲人成影院在线观| 免费人成年轻人电影| 久久久久免费精品国产| 91在线亚洲综合在线| 国产亚洲欧洲Aⅴ综合一区| 国内精自视频品线六区免费| 激情小说亚洲图片| 亚洲av综合色区| 国产不卡免费视频| 最近最新高清免费中文字幕| 日韩精品亚洲专区在线影视| 久久精品国产亚洲av成人| 四虎影院免费在线播放|