how to get the datePicker value, intercept it, make changes, and then put it yourself in the input. This is my code, so it inserts a date into the component, and I need the date to fit in the variable only.

$( e.target).datepicker({ onSelect: date => { console.log(date); } }).focus(); 
  • And what changes do you want to make with the date? - Arsen
  • put in a variable and not output to input. - first last

1 answer 1

 $(function() { $('#datepicker').datepicker({ onSelect: date => { console.log(date); $('#datepicker').datepicker('setDate', null); } }); }); 
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <p>Date: <input type="text" id="datepicker"></p>