国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
常見的JS驗(yàn)證

js中String的常用擴(kuò)展,包括trim,檢查中文,url,emal,電話號(hào)碼,轉(zhuǎn)類型,格式化代碼等
//去掉字符串空間調(diào)用方式 字符串.trim()   
String.prototype.trim = function()...{ return this.replace(/(^\s*)|(\s*$)/g, "");}       
 
//求字符穿真實(shí)長(zhǎng)度漢字2個(gè)字節(jié) 字符串.lengthw()   
String.prototype.lengthW = function()...{ return this.replace(/[^\x00-\xff]/g,"**").length;}   
 
//判斷是否email   
String.prototype.isEmail = function()...{ return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(this);}   
 
// 字符串中是否包含中文   
String.prototype.existChinese = function()...{return /^[\x00-\xff]*$/.test(this);}     
 
//檢查url     
String.prototype.isUrl = function()...{ return /^http[s]?:\/\/([\w-]+\.)+[\w-]+([\w-./?%&=]*)?$/i.test(this);}   
 
//檢查電話號(hào)碼   
String.prototype.isPhoneCall = function()...{ return /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(this);}   
 
//檢查整數(shù)   
String.prototype.isNumber=function()...{return /^[0-9]+$/.test(this);}   
 
// 整數(shù)轉(zhuǎn)換   
String.prototype.toNumber = function(def)...{return isNaN(parseInt(this, 10)) ? def : parseInt(this, 10);}     
 
// 小數(shù)轉(zhuǎn)換   
String.prototype.toMoney = function(def)...{return isNaN(parseFloat(this)) ? def : parseFloat(this);} 

//格式化代碼
String.prototype.format = function() ...{
    var args = arguments;
    return this.replace(/{(\d{1})}/g, function() ...{
        return args[arguments[1]];
    });
}; 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
JS過濾空格
項(xiàng)目開發(fā)中非常有用的js處理函數(shù)(本人原創(chuàng))
正則表達(dá)式的JS驗(yàn)證
JS 中 new 操作符
JavaScript字符串函數(shù)大全
在JS中用Replace 全部替換字符
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服