<html>
<body>
<input type="button" id="check" value="チェック">
</body>
</html>
$(function(){
  $("#check").click(function(){
    var result = "<br>";
    if(isDate(2019,12,1)){
      result += "<br>2019,12,1: 日付!";
    } else {
      result += "<br>2019,12,1: エラー";
    }
    if(isDate(2019,12,01)){
      result += "<br>2019,12,01: 日付!";
    } else {
      result += "<br>2019,12,01: エラー";
    }
    if(isDate(2019,'',1)){
      result += "<br>2019,'',1: 日付!";
    } else {
      result += "<br>2019,'',1: エラー";
    }
    if(isDate(2019,'12',1)){
      result += "<br>2019,'12',1: 日付!";
    } else {
      result += "<br>2019,'12',1: エラー";
    }
    if(isDate(2019,'date',1)){
      result += "<br>2019,'date',1: 日付!";
    } else {
      result += "<br>2019,'date',1: エラー";
    }
    if(isDate(2019,13,1)){
      result += "<br>2019,13,1: 日付!";
    } else {
      result += "<br>2019,13,1: エラー";
    }
    if(isDate(2019,12,50)){
      result += "<br>2019,12,50: 日付!";
    } else {
      result += "<br>2019,12,50: エラー";
    }

    $("#check").after(result);
  });

  function isDate(y,m,d) {
    var date = new Date(y,m-1,d);
    if(date.getFullYear()==y &&  date.getMonth()==m-1 && date.getDate()==d) {
      return true;
    } else {
      return false;
    }
 }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js