Get datetimepicker result in span

1

I am getting the results of text input in spans, but in the input where I have the calendar with datetimepicker, it does not send the value. The script works well with text inputs, but with the one with datetimepicker it does not.

Search a lot but I could not find the solution, which can be?

<input type="text" name="vtoDias2" id="fecha3" placeholder="Ingrese Fecha"> 


<span id="numFecha3"></span>

<script>
 $("input[name=vtoDias2]").on('keyup', function () {
 $('#numFecha3').html($(this).val());
 });  
 </script>
    
asked by Elias Aria 05.04.2018 в 23:43
source

1 answer

1

If you refer to the jQuery datePicker plugin (although it probably happens the same with others), the problem is probably that the date is taken from a calendar by the mouse, not by the keyboard.

To detect when the value changes you should listen to the event change of the input:

<script>
$("input[name=vtoDias2]").on('change', function (e) {
  $('#numFecha3').html($(this).val());
});  
</script>
    
answered by 06.04.2018 / 04:26
source