combine from/to input[type="date"] fields

by trixta

HTML

<script src="http://afarkas.github.com/webshim/js-webshim/minified/polyfiller.js"></script>
<form action="#">
    
    <div>
        <label for="fromDate">from</label>
        <input type="date" id="fromDate" required="" />
        <label for="toDate">to</label>
        <input type="date" id="toDate" required="" />
    </div>
    <div>
        <input type="submit" />
    </div>
</form>

JavaScript

webshim.polyfill('forms forms-ext');

jQuery(function($) {
    $('#fromDate').on('change', function() {
        $('#toDate').prop('min', $(this).val());
    });
    $('#toDate').on('change', function() {
        $('#fromDate').prop('max', $(this).val());
    });

});