상용 데이터 형식 검사 및 장치 식별 도구
8869 단어 자바 script
값 형식 검사
핸드폰 번호 검사
암호 검사
중국어 검사
메 일 박스 검사
검사 장치 시스템
휴대 전화 장치 인지 검사 하 다.
검 측 ios
안 드 로 이 드 검색
Mac 검사 계통
Windows 시스템 검색
Safari 브 라 우 저 검색
플래시 플러그 인 검색
검 측 데이터 형식
검사 Null
검 측 부정 확
검색 Boolean
검 측 문자열
검사 번호
NaN 검출
검 측 개체
검 측 어 레이
검 측 RegExp
검 측 지도
검 측 Promise
검사 날짜
검출 수학
JSON 검사
기타
HTML 구조 에서 html 태그 제거
UUID 생 성
시간 처리 장치
값 형식 검사
핸드폰 번호 검사
/**
*
* @param {String | Number} value
* @returns {Boolean}
*/
export function isMobile(value) {
const REG_MOBILE = /^1(3|4|5|6|7|8|9)[0-9]{9}$/
return REG_MOBILE.test(value)
}
암호 검사
/**
*
* @param {String | Number} value
* @returns {Boolean}
*/
export function(value) {
const REG_PASSWORD = /^[0-9a-zA-Z]{6,20}$/
return REG_PASSWORD.test(value)
}
중국어 검사
/**
*
* @param {String} value
* @returns {Boolean}
*/
export function isChineseString(value) {
const REG_CHINESE_STRING = /[^(\u4e00-\u9fa5)]{8,24}/
return REG_CHINESE_STRING.test(value)
}
메 일 박스 검사
/**
*
* @param {String} value
* @returns {Boolean}
*/
export function isEmail(value) {
const REG_EMAIL = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/
return REG_EMAIL.test(value)
}
검사 장치 시스템
휴대 전화 장치 인지 검사 하 다.
/**
*
*/
export function isMobileDevice() {
const userAgent = window.navigator.userAgent
return !!userAgent.match(/AppleWebKit.*Mobile.*/)
}
검 측 ios
/**
* IOS
*/
export function isIOS() {
const REG_IOS = /iphone|ipad|ipod/
return REG_IOS.test(userAgent)
}
안 드 로 이 드 검색
/**
* android
*/
export function isAndroid() {
const REG_ANFROID = /android/
return REG_ANFROID.test(userAgent)
}
Mac 검사 계통
/**
* MAC
*/
export function isMac() {
const REG_MAC = /macintosh|mac os x/i
return REG_MAC.test(userAgent)
}
Windows 시스템 검색
/**
* WINDOWS
*/
export function isWindows() {
const REG_WINDOWS = /windows|win32/i
return REG_WINDOWS.test(userAgent)
}
Safari 브 라 우 저 검색
/**
* Safari
*/
export function isSafari() {
const REG_SAFARI = /safari/
const REG_CHROME = /chrome/
return REG_SAFARI.test(userAgent) && !REG_CHROME.test(userAgent)
}
플래시 플러그 인 검색
/**
* flash
* :
* 1. ,
* 2. 、 、 Edge、Safari ActiveXObject, navigator.plugins
* 3. chrome flash
*/
export function isFlash() {
let flash
if (typeof window.ActiveXObject != 'undefined') {
flash = window.ActiveXObject('ShockwaveFlash.ShockwaveFlash')
} else {
flash = navigator.plugins['Shockwave Flash']
}
return flash ? true : false
}
검 측 데이터 형식
검사 Null
export function isNull(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Null]'
}
검 측 부정 확
export function isUndefined(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Undefined]'
}
검색 Boolean
export function isBoolean(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Boolean]'
}
검 측 문자열
export function isString() {
const type = Object.prototype.toString
return type.call(value) === '[object String]'
}
검사 번호
export function isNumber(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Number]'
}
NaN 검출
export function isNaN(value) {
const type = Object.prototype.toString
return type.call(value) === '[object NaN]'
}
검 측 개체
/**
*
* @param {*} value
*/
export function isObject(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Object]'
}
검 측 어 레이
/**
*
* @param {Array} value
*/
export function isArray (value) {
const type = Object.prototype.toString
return type.call(value) === '[object Array]'
}
검 측 RegExp
export function isRegExp(value) {
const type = Object.prototype.toString
return type.call(value) === '[object RegExp]'
}
검 측 지도
export function isMap(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Map]'
}
검 측 Promise
export function isPromise(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Promise]'
}
검사 날짜
export function isDate(value) {
const type = Object.prototype.toString
reutrn type.call(value) === '[object Date]'
}
검출 수학
export function isMath(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Math]'
}
JSON 검사
export function isJSON(value) {
const type = Object.prototype.toString
return type.call(value) === '[object JSON]'
}
검사 오류
export function isError(value) {
const type = Object.prototype.toString
return type.call(value) === '[object Error]'
}
기타
HTML 구조 에서 html 태그 제거
/**
* html text( html )
* @param {String} value html
*/
export function htmlToText(value) {
const REG_HTML_TO_TEXT = //g
return value.replace(REG_HTML_TO_TEXT, '')
}
UUID 생 성
/**
* UUID
*/
export function createUuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0
const v = c == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}
시간 처리 장치
/**
*
* @param {String} value
*/
export function moment() {
var datetime = new Date()
if (typeof value === 'string' && /^[0-9]{4}(\-|\/)[0-9]{1,2}(\-|\/)[0-9]{1,2}/.test(value)) {
datetime = new Date(value.replace(/\-/g, '/'))
} else if (Object.prototype.toString.call(value) === '[object Date]') {
datetime = value
}
function repair(value) {
return value > 9 ? value : `0${value}`
}
function format(type) {
var datetime_format,
Y = datetime.getFullYear(),
M = datetime.getMonth() + 1,
D = datetime.getDate(),
H = datetime.getHours(),
m = datetime.getMinutes(),
s = datetime.getSeconds()
switch (type) {
case 'YYYY-MM':
datetime_format = `${Y}-${repair(M)}`
break;
case 'YYYY-MM-DD':
datetime_format = `${Y}-${repair(M)}-${repair(D)}`
break;
case 'HH:mm':
datetime_format = `${repair(H)}:${repair(m)}`
break;
case 'HH:mm:ss':
datetime_format = `${repair(H)}:${repair(m)}:${repair(s)}`
break;
case 'YYYY-MM-DD HH:mm':
datetime_format = `${Y}-${repair(M)}-${repair(D)} ${repair(H)}:${repair(m)}`
break;
case 'YYYY-MM-DD HH:mm:ss':
datetime_format = `${Y}-${repair(M)}-${repair(D)} ${repair(H)}:${repair(m)}:${repair(s)}`
break;
case 'YYYY/MM':
datetime_format = `${Y}/${repair(M)}`
break;
case 'YYYY/MM/DD':
datetime_format = `${Y}/${repair(M)}/${repair(D)}`
break;
case 'YYYY/MM/DD HH:mm':
datetime_format = `${Y}/${repair(M)}/${repair(D)} ${repair(H)}:${repair(m)}`
break;
case 'YYYY/MM/DD HH:mm:ss':
datetime_format = `${Y}/${repair(M)}/${repair(D)} ${repair(H)}:${repair(m)}:${repair(s)}`
break;
default:
break;
}
}
return {
format
}
}
//
moment().format('YYYY-MM-DD HH:mm:ss')
moment('2020-12-12 23:23:24').format('HH:mm:ss')
moment('2020/12/12 23:23:24').format('YYYY-MM')
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Thymeleaf 의 일반 양식 제출 과 AJAX 제출텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.