当前位置:网站首页>正则校验与时间格式化
正则校验与时间格式化
2022-07-28 23:58:00 【黑白两客】
// 日期回显
export function formatTime(data,famet='YYYY-MM-DD HH:MMM:SS') {
if(famet == 'YYYY-MM-DD HH:MMM:SS'){
const time = new Date(data)
const year = time.getFullYear()
const month = time.getMonth() + 1
const day = time.getDate()
const hour = time.getHours()
const minute = time.getMinutes()
const second = time.getSeconds()
return year + '-' + month + '-' + day
}
}
// 校验
export function reg(data) {
//你输入的手机号长度或格式错误
let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{
8}$/
// 姓名格式校验
let reg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{
2,6}$/;
//身份证号校验
let reg = /^[1-9]\d{
7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{
3}$|^[1-9]\d{
5}[1-9]\d{
3}((0\d)|(1[0-2]))
if (!reg.test(data)) {
uni.showToast({
title: "你输入的手机号长度或格式错误",
icon: 'none'
});
return false
}
return true
}
边栏推荐
猜你喜欢

Self made | a 16 bit RISC architecture CPU is self-made by hand

Copy the table in word to wechat as a picture and send it

状态压缩dp-蒙德里安的梦想

The method of tracking the real-time market of London Silver

图扑软件亮相 2022 福州数博会,携手共创数字新时代

Inftnews | yuanuniverse shopping experience will become a powerful tool to attract consumers

Talk about the cross end technical scheme

SystemVerilog-连接和复制运算符

【Jenkins笔记】入门,自由空间;持续集成企业微信;allure报告,持续集成电子邮件通知;构建定时任务

Visual full link log tracking
随机推荐
时序预测 | MATLAB实现TCN时间卷积神经网络的时间序列预测
线程锁及锁的升降级
How to carry out engineering implementation of DDD Domain Driven Design
【树莓派】widows电脑如何与树莓派连接
转:认知亚文化
【commons-lang3专题】002- RandomUtils 专题
mysql存储过程 实现创建一张表(复制原表的结构新建的表)
“index [hotel/jXLK5MTYTU-jO9WzJNob4w] already exists“
图扑软件亮相 2022 福州数博会,携手共创数字新时代
🧐 Table1 | finish your third line watch in one second
Have you seen the management area decoupling architecture? Can help customers solve big problems
Summary of preprocessing methods for time series data
Plato launched the LAAS protocol elephant swap, which allows users to earn premium income
ThinkPHP high imitation blue cloud disk system program
Introduction to FLV documents
Summary of process and thread knowledge points 2
机器学习 | MATLAB实现RBF径向基神经网络newrbe参数设定
[unity] configure unity edit C as vscode
递归与分治
日期转换 EEE MMM dd HH:mm:ss zzz yyyy