title: Get value from date input (JS)
body: <p>I have view with two inputs where dates loading </p>
  
  <p>Here is code in View of these inputs</p>
  
  <pre><code>&lt;div class="device-selection"&gt;
      &lt;label for="startDate"&gt;@Dictionary.General.StartDate: &lt;/label&gt;
      &lt;input id="startDate" class="round-input text-right" readonly /&gt;
  &lt;/div&gt;
  
  &lt;div class="device-selection"&gt;
      &lt;label for="endDate"&gt;@Dictionary.General.EndDate: &lt;/label&gt;
      &lt;input id="endDate" class="round-input text-right" readonly /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In JS I have this code for showing calendar and populating inputs with dates:</p>
  
  <pre><code>  $(document).ready(function () {
  
  //cultureTwoLetterName is a global variable from the view that contains the two letter iso language name
      $.datepicker.setDefaults($.datepicker.regional[cultureTwoLetterName]);
  
      $('#calendar').weekMonthDatepicker({
          changeMonth: true,
          dateFormat: 'yy-mm-dd',
          showWeek: true,
          firstDay: 1,
          weekHeader: '&lt;span class="glyphicon glyphicon-arrow-down"&gt;&lt;/span&gt;',
          minDate: -loggingRetention,
          maxDate: '+0D',
          weekSelection: true,
          weekSelected: SelectionCallback,
          monthSelection: true,
          monthSelected: SelectionCallback
      });
  
      $('#startDate').datepicker({
          changeMonth: true,
          dateFormat: 'yy-mm-dd',
          firstDay: 1,
          minDate: -loggingRetention,
          maxDate: '+0D'
      });
  
  
      $('#endDate').datepicker({
          changeMonth: true,
          dateFormat: 'yy-mm-dd',
          firstDay: 1,
          minDate: -loggingRetention,
          maxDate: '+0D'
      });
  
  
      $('#calendar').on('change', function () {
          $('#startDate').val(moment($(this).val()).format('DD/MM/YYYY'));
          $('#endDate').val(moment($(this).val()).format('DD/MM/YYYY'));
          var start = $('#calendar').weekMonthDatepicker('getStartDate');
          var stop = $('#calendar').weekMonthDatepicker('getEndDate');
          var ui;
  
          if (start != null &amp;&amp; stop != null) {
              ui = { 'startDate': start, 'endDate': stop };
  
          }
  
          PopulateTableDetails(null, ui);
      });
  
      $('#startDate').on('change', function () {
          $(this).val(moment($(this).val()).format('DD/MM/YYYY'));
  
          if ($('#endDate').val() == '' || moment($('#endDate').val(), 'DD/MM/YYYY') &lt; moment($(this).val(), 'DD/MM/YYYY')) { //endDate niet ingevuld of &lt; startDate --&gt; endDate = startDate
              $('#endDate').val($(this).val());
          }
  
          var start = moment($(this).val(), 'DD/MM/YYYY');
          var stop = moment($('#endDate').val(), 'DD/MM/YYYY');
  
          var ui = { 'startDate': start, 'endDate': stop };
  
          PopulateTableDetails(null, ui);
      });
  
      $('#endDate').on('change', function () {
          $(this).val(moment($(this).val()).format('DD/MM/YYYY'));
  
          if ($('#startDate').val() == '' || moment($('#startDate').val(), 'DD/MM/YYYY') &gt; moment($(this).val(), 'DD/MM/YYYY')) { //startDate niet ingevuld of &gt; endDate --&gt; startDate = endDate
              $('#startDate').val($(this).val());
          }
  
          var start = moment($('#startDate').val(), 'DD/MM/YYYY');
          var stop = moment($(this).val(), 'DD/MM/YYYY');
          var ui = { 'startDate': start, 'endDate': stop };
  
         });
      }); 
  </code></pre>
  
  <p>I need to get values from startDate and endDate </p>
  
  <p>So I try to write <code>var startvalue = $('#startDate').val();</code></p>
  
  <p>In this function <code>$('#calendar').on('change', function () {</code></p>
  
  <p>But I get empty alert with this code.</p>
  
  <p>How I can get value of it correctly?</p>
  
  <p>Thank's for help so much.</p>