JS日期格式校验/判断
function checkDate(dateStr){
var a = /^(\d{4})-(\d{2})-(\d{2})$/
if (!a.test(dateStr)) {
return false
}else{
return true;
}
}
直接调用方法:
if(!checkDate("2019-05-29")){
alert("格式不正确!");
}else{
alert("格式正确!");
}
原文链接:https://blog.csdn.net/pk694046220/article/details/90671217