var str='2019-09-20 20:05' if(/^\d{4}-\d{2}-\d{2}$/.test(str)){ alert("格式正确!"); }else{ alert('格式错误') }