Validate that end date is greater than start date with jQuery

前端 未结 15 1871
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 13:14

How do I check/validate in jQuery whether end date [textbox] is greater than start date [textbox]?

15条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 13:33

    In javascript/jquery most of the developer uses From & To date comparison which is string, without converting into date format. The simplest way to compare from date is greater then to date is.

    Date.parse(fromDate) > Date.parse(toDate)
    

    Always parse from and to date before comparison to get accurate results

提交回复
热议问题