js-日期格式正则检验

let re =/^(\d{4})-(\d{2})-(\d{2})$/;
let str = "2022-06-22";
if (re.test(str) {
   console.log("验证成功!")
}

 

posted @ 2022-06-22 10:19  scwyfy  阅读(283)  评论(0编辑  收藏  举报