How do I restrict the start date and the end date to the same month?

How do I restrict the start date and the end date to the same month?

  1. <script type="text/javascript">

  2.     $(function() {
  3.         $( "#from" ).datepicker({
  4.             defaultDate: "+1w",
  5.             numberOfMonths: 1,
  6.             onSelect: function( selectedDate ) {
  7.                 $( "#to" ).datepicker( "option", "minDate", selectedDate );
  8.                   
  9.             }
  10.         });
  11.         
  12.         $( "#to" ).datepicker({
  13.             defaultDate: "+1w",
  14.             numberOfMonths: 1,
  15.             onSelect: function( selectedDate ) {
  16.                 $( "#from" ).datepicker( "option", "maxDate", selectedDate );
  17.             }
  18.         });
  19.     
  20.         $( "input[type=submit]" )
  21.             .button()
  22.     
  23. });
  24. </script>