仅比较时间值

时间:2016-05-04 10:53:18

标签: javascript jquery html jquery-ui

我想比较两个时间值。就像从时间到时间。我无法达到这样的要求,到时间应始终大于从时间。 我正在使用jquery时间选择器。请帮助我成为新的蜜蜂。

下面是我的代码

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.timeselect.js"></script>
<script type="text/javascript" src="js/date-en-US.js"></script>
<script>
    $(function() {
        $('.tp').timeselect({
            'step': 30,
            'format': 'HH:mm',
            autocompleteSettings: {
                autoFocus: true 
            }
        });
    });
</script>

<div class="detail_items2" id="fromTimeDiv">
    <p><label id="fromTimeDiv_Label" for="fromTime_label" class="blue_text2">From Time <font style="color:red;">*</font></label></p>
    <input type="text"  class="tp" name="fromTime" id="fromTime" maxlength="75"  value=""   onKeyPress="document.getElementById('fromTime_error').innerHTML='';"/>
</div>
<div class="detail_items2" id ="toTimeDiv">
    <p><label id="toTimeDiv_Label" for="toTime_label" class="blue_text2">To Time <font style="color:red;">*</font></label></p>
    <input type="text" class="tp"  name="toTime" id="toTime" maxlength="75"  value=""   onKeyPress="document.getElementById('toTime_error').innerHTML='';"/>
</div>

对于日期,我将比较如下。请及时帮助我,即时间应始终大于时间

if(toDate<fromDate){
    alert("To Date should be greater than or equal to From Date");
    $("input#toDate").focus();
    return false;
}
if (fromTime == "") {
    $("label#fromTime_error").show();
    document.getElementById("fromTime_error").innerHTML="This field is Required.";
    $("input#fromTime").focus();
    document.getElementById("imageCheck").checked = false;
    return false;
}
if (toTime == "") {
    $("label#toTime_error").show();
    document.getElementById("toTime_error").innerHTML="This field is Required.";
    $("input#retoTimeco").focus();
    document.getElementById("imageCheck").checked = false;
    return false;
}

0 个答案:

没有答案