Commit f9769235 authored by 郝聪敏's avatar 郝聪敏

fix: 校验日期合法性

parent cf80ed71
...@@ -242,6 +242,11 @@ export function getBirthDate(idCard) { ...@@ -242,6 +242,11 @@ export function getBirthDate(idCard) {
birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-"); birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
} }
if (birthday && !isValidDate(new Date(birthday))) {
birthday = "";
}
return birthday; return birthday;
} }
...@@ -307,3 +312,8 @@ export function onKeyboardStateChange(callback = () => {}, off = false) { ...@@ -307,3 +312,8 @@ export function onKeyboardStateChange(callback = () => {}, off = false) {
} }
} }
} }
// 校验是否合法日期
export function isValidDate(date) {
return date instanceof Date && !isNaN(date.getTime());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment