如何在结束时将结束日期与开始日期进行比较,以确保结束日期大于开始日期

时间:2016-03-27 00:19:05

标签: javascript twitter-bootstrap-3

我是编码世界的新手。我正在使用bootstrap创建一个网页,以便在页面中显示“开始日期”和“结束日期”。但问题是我不知道如何使结束日期始终大于开始日期。我在这里粘贴了我从互联网上获得的代码。任何帮助将不胜感激This is how the page looks like right now

<script>
$(document).ready(function() {
    $('#dateRangePicker')
        .datepicker({
            format: 'mm/dd/yyyy',
            startDate: '01/01/2010',
            endDate: '12/30/2020'
        })
        .on('changeDate', function(e) {
            // Revalidate the date field
            $('#dateRangeForm').formValidation('revalidateField', 'date');
        });
    $('#dateRangePicker1')
    .datepicker({
        format: 'mm/dd/yyyy',
        startDate: '01/01/2010',
        endDate: '12/30/2020'
    })
    .on('changeDate', function(e) {
        // Revalidate the date field
        $('#dateRangeForm').formValidation('revalidateField', 'date');
    });

    $('#dateRangeForm').formValidation({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            date: {
                validators: {
                    notEmpty: {
                        message: 'The date is required'
                    },
                    date: {
                        format: 'MM/DD/YYYY',
                        min: '01/01/2010',
                        max: '12/30/2020',
                        message: 'The date is not a valid'
                    }
                }
            }
        }
    });
});
</script>
<div class="form-group">
        <label class="control-label col-sm-3">Start Date</label>
        <div class="col-sm-6">
            <div class="input-group input-append date" id="dateRangePicker">
                <input type="text" class="form-control" name="date" />
                <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
            </div>
        </div>
    </div>
     
    <div class="form-group">
        <label class="control-label col-sm-3">End Date</label>
        <div class="col-sm-6">
            <div class="input-group input-append date" id="dateRangePicker1">
                <input type="text" class="form-control" name="date" />
                <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
            </div>
        </div>
    </div>

1 个答案:

答案 0 :(得分:0)

如果我不误解这个问题,我已经看到很多相关的消息来源。 其中一个是#12821033