I have a bootstrap date picker that has a multidate function and I want to count the number of days selected on change but it doesn't only return the present value but also the previous value. Slicing and Trimming don't work apparently.
The Code I'm using to alert the datecount
$(document).on('change', '#leavedate', function (e){
e.preventDefault();
const date = $('#leavedate').val();
const datelength = date.length;
alert(datelength);
})