Validate that end date is greater than start date with jQuery

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

    Little late to the party but here is my part

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

    Here is the detail:

    var from = $("#from").val();
    var to = $("#to").val();
    
    if(Date.parse(from) > Date.parse(to)){
       alert("Invalid Date Range");
    }
    else{
       alert("Valid date Range");
    }
    

提交回复
热议问题