0

I am new to coding world. I am making a webpage using bootstrap to take in 'Start date' and 'End date' in the page. But the problem is I don't know how to make end date always greater than start date. I have pasted the code here which I got from the internet. Any help will be appreciatedThis 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 Answers1

0

I have seen lots of sources related if I don't misunderstand the question. One of them is #12821033.

Community
  • 1
  • 1
Melih
  • 341
  • 4
  • 15
  • the problem is I don't have experience with JSP. So, if I can get a clear code on how to take startDate and endDate and compare them like endDate - startDate>0, then it would be awesome. – Siddhant Jain Mar 27 '16 at 03:29