From f1352a893f6375f27e0ec25ea8ebbb198032d0b0 Mon Sep 17 00:00:00 2001 From: luo <17530855@qq.com> Date: Mon, 5 Feb 2024 16:15:33 +0800 Subject: [PATCH] 注册生日优化 --- packageA/pages/profile/profile.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index e0b63cf..31caaab 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -1159,22 +1159,43 @@ Page({ console.log(e); let b = this.getInput(e); let reg=/^[0-9\-]*$/ + // let reg=/^\d{4}-\d{1,2}-\d{1,2}$/ if (!(reg.test(b))){ return this.data.oldbirthday } + let length = b.length; let oldBirtthDayLength=this.data.oldBirtthDayLength if (length > oldBirtthDayLength) { + if (b.length==4) { b+='-' } + if (b.length==6 && b[5] >1) { + console.log(b[5]); + return this.data.oldbirthday + } + if (b.length==7) { - b+='-' + if (b[6]=='-') { + let lb = b.split(''); + lb.splice(5, 0, 0); + b = lb.join(''); + }else{ + b+='-' + } + + } + + if (b.length==10) { + let a=b[8]+b[9]; + if (a*1>31) { + return this.data.oldbirthday + } } - // if (b.length==6 && b[5] >1) { - // console.log(b[5]); - // } + + } this.setData({ datet: b, -- libgit2 0.21.4