Field date with jQuery does not set the chosen value

0

I'm using a jQuery-UI datePicker to generate date in an "input text" field, but I can not get the date selected in the datePicker to be set on that input and I do not understand what's wrong.

What is missing in this code so that input text From and input text To have their values changed?

    <script src="/javascripts/jquery/jquery-1.12.4.js"></script>
    <script src="/javascripts/jquery//jquery-ui.js"></script>  <script>
  $( function() {
    var dtFormat = "dd/mm/yy",
      from = $( "#from" )
        .datepicker({
          //defaultDate: "+1w",
          changeMonth: true,
          numberOfMonths: 1,
          dateFormat: dtFormat,
          altFormat: "yy-mm-dd"
        })
        .on( "change", function() {
          to.datepicker( "option", "minDate", getDate( this ) );
        }),
      to = $( "#to" ).datepicker({
        //defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 1,
        dateFormat: dtFormat,
        altFormat: "yy-mm-dd"
      })
      .on( "change", function() {
        from.datepicker( "option", "maxDate", getDate( this ) );
      });

    function getDate( element ) {
      var date;
      try {
        date = $.datepicker.parseDate( dtFormat, element.value );
      } catch( error ) {
        date = null;
      }

      return date;
    }
  } );
  </script>
  </head>
  <body>
    <form class="form-horizontal well" method="post" action="/report">
      <label for="from">From</label>
      <input type="text" id="from" name="from">
      <label for="to">To</label>
      <input type="text" id="to" name="to">
      <input class="button btn-default" type="submit" value="Gerar Relatório">
      <table width="100%">
    
asked by anonymous 26.07.2017 / 18:28

1 answer

0

I've solved it. In the input text from and input text to fields, the value="" attribute was missing.

Then it stayed:

<input type="text" id="from" name="from" value="">
<input type="text" id="to" name="to" value="">

In this way date values are sent in POST .

    
26.07.2017 / 20:34