Validate that end date is greater than start date with jQuery

前端 未结 15 1663
隐瞒了意图╮
隐瞒了意图╮ 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:21

    I like what Franz said, because is what I'm using :P

    var date_ini = new Date($('#id_date_ini').val()).getTime();
    var date_end = new Date($('#id_date_end').val()).getTime();
    if (isNaN(date_ini)) {
    // error date_ini;
    }
    if (isNaN(date_end)) {
    // error date_end;
    }
    if (date_ini > date_end) {
    // do something;
    }
    

提交回复
热议问题