網站首頁 前端文檔 正文
1.郵箱
export const isEmail = (e) => { return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(e) }
2.手機號碼
export const isMobile = (e) => { return /^1[0-9]{10}$/.test(e) }
3.電話號碼
export const isPhone = (e) =>{ return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(e) }
4.是否url地址
export const isURL = (e) => { return /^http[s]?:\/\/.*/.test(e) }
5.是否字符串
export const isNumber = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1) === 'String' }
6.是否數字
export const isNumber = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1) ==='Number' }
7.是否boolean
export const isBoolean = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1) ==='Boolean' }
8.是否函數
export const isFunction = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1) === 'Function' }
9.是否為null
export const isNull = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Null' }
10.是否undefined
export const isUndefined = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Undefined' }
11.是否對象
export const isObject = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1) === 'Object' }
12.是否數組
export const isArray = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Array' }
13.是否時間
export const isDate = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Date' }
14.是否正則
export const isRegExp = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='RegExp' }
15.是否錯誤對象
export const isError = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Error' }
16.是否Symbol函數
export const isSymbol = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Symbol' }
17.是否Promise對象
export const isPromise = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1)==='Promise' }
18.是否Set對象
export const isSet = (e) =>{ return Object.prototype.toString.call(e).slice(8,-1) ==='Set' } export const us = navigator.userAgent.toLowerCase();
19.是否是微信瀏覽器
export const isWeiXin = () =>{ return ua.match(/microMessenger/i) == 'micromessenger' }
20.是否是移動端
export const isDeviceMobile =()=>{ return /android|webos|iphone|ipod|balckberry/i.test(ua) }
原文鏈接:https://juejin.cn/post/7030346779539275806
相關推薦
- 2022-03-14 Go使用Gin框架開發博客系統(一)之環境搭建和項目初始化
- 2022-08-31 C++?OpenCV裁剪圖片時發生報錯的解決方式_C 語言
- 2022-05-27 Python?nonlocal關鍵字?與?global?關鍵字解析_python
- 2022-05-15 C++的數據共享與保護你了解嗎_C 語言
- 2023-10-16 elementUI日期選擇器快速選擇 快捷選擇(本周、上周、本月、上月、季度等)
- 2022-10-23 Redis?異常?read?error?on?connection?的解決方案_Redis
- 2022-07-03 C語言詳解strcmp函數的分析及實現_C 語言
- 2022-04-27 幾個關于python??Pdf?技巧的分享_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支