Jquery DateJs, is there validation for full date?

后端 未结 2 1248
遥遥无期
遥遥无期 2021-01-15 19:09

I just find out about the power of date js, And its great!!! As I am a newbie I was wondering if there is any kind of general validitation for different types of full dates.

2条回答
  •  滥情空心
    2021-01-15 19:56

    Here I am answering your question again.

    To validate a date, you can simply call:

    var d1 = "200-10-18, 10:06 AM";
    Date.validateDay(d1); 
    

    And it will tell you if the date is valid.

    EDIT

    Or, you can simply do this:

    var d = Date.parseExact("2008-03-08", "yyyy-MM-dd"); 
    if (d !== null) { 
         alert('Date = ' + d.toString('MMMM dd, yyyy')); 
    } 
    

    Using parseExact will return null in case the date is not valid.

提交回复
热议问题