How do I validate a date in this format (yyyy-mm-dd) using jquery?

前端 未结 11 1328
长情又很酷
长情又很酷 2020-12-02 11:41

I am attempting to validate a date in this format: (yyyy-mm-dd). I found this solution but it is in the wrong format for what I need, as in: (mm/dd/yyyy).

Here is t

11条回答
  •  春和景丽
    2020-12-02 12:04

     moment(dateString, 'YYYY-MM-DD', true).isValid() ||
     moment(dateString, 'YYYY-M-DD', true).isValid() ||
     moment(dateString, 'YYYY-MM-D', true).isValid();
    

提交回复
热议问题