0

I have two datepickers:

<script type="text/javascript">
    jQuery(function() {
        jQuery( '#startdatepicker' ).datepicker();
    });
</script>

<script type="text/javascript">
    jQuery(function() {
        jQuery( '#enddatepicker' ).datepicker();
    });
</script>

How can I modify to it so that the default date is today's date for both the date pickers?

I'd like it if the start date is picked to a different date, allow end date to be picked >= the start date. If the end date is modified first, allow the start date to be <= to end date.

<td align='center'>Start Date:<input type='text' name='start_date' id='startdatepicker' /></td>
<td align='center'>End Date: <input type='text' name='end_date' id='enddatepicker'  /></td>
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Micheal
  • 2,272
  • 10
  • 49
  • 93

1 Answers1

0

You can use the options of the datepicker plugin. jQuery date picker manipulations

You can also try looking at the previously asked stack overflow question: How do I pre-populate a jQuery Datepicker textbox with today's date?

Here is the sample code

$(document).ready(function(){
    $("#startdatepicker").datepicker({ 
    });
    var myDate = new Date();
    var month = myDate.getMonth() + 1;
    var prettyDate = month + '/' + myDate.getDate() + '/' + myDate.getFullYear();
    $("#startdatepicker").val(prettyDate);
});
Community
  • 1
  • 1
Shubhanshu Mishra
  • 6,210
  • 6
  • 21
  • 23