Commit f1352a893f6375f27e0ec25ea8ebbb198032d0b0

Authored by 前端开发-罗建龙
1 parent 92a480dc

注册生日优化

packageA/pages/profile/profile.js
... ... @@ -1159,22 +1159,43 @@ Page({
1159 1159 console.log(e);
1160 1160 let b = this.getInput(e);
1161 1161 let reg=/^[0-9\-]*$/
  1162 + // let reg=/^\d{4}-\d{1,2}-\d{1,2}$/
1162 1163 if (!(reg.test(b))){
1163 1164 return this.data.oldbirthday
1164 1165 }
  1166 +
1165 1167 let length = b.length;
1166 1168 let oldBirtthDayLength=this.data.oldBirtthDayLength
1167 1169 if (length > oldBirtthDayLength) {
  1170 +
1168 1171 if (b.length==4) {
1169 1172 b+='-'
1170 1173 }
  1174 + if (b.length==6 && b[5] >1) {
  1175 + console.log(b[5]);
  1176 + return this.data.oldbirthday
  1177 + }
  1178 +
1171 1179 if (b.length==7) {
1172   - b+='-'
  1180 + if (b[6]=='-') {
  1181 + let lb = b.split('');
  1182 + lb.splice(5, 0, 0);
  1183 + b = lb.join('');
  1184 + }else{
  1185 + b+='-'
  1186 + }
  1187 +
  1188 + }
  1189 +
  1190 + if (b.length==10) {
  1191 + let a=b[8]+b[9];
  1192 + if (a*1>31) {
  1193 + return this.data.oldbirthday
  1194 + }
1173 1195 }
1174   - // if (b.length==6 && b[5] >1) {
1175   - // console.log(b[5]);
1176 1196  
1177   - // }
  1197 +
  1198 +
1178 1199 }
1179 1200 this.setData({
1180 1201 datet: b,
... ...