Date picker issue on form submit

137 Views Asked by At

How can I assign the currently selected date instead of new date() in the following code?

So from here each time when I refresh, it will give me currently selected date in textbox instead of becoming blank

$(".date-pick").datepicker('setDate', new Date());
1

There are 1 best solutions below

1
kavetiraviteja On BEST ANSWER

try this ..

use onclose event of datepicker to set the value of date .... "$(this).val()" this will have the value of currently selected date and set this value to Html Element using "document.getElementsByClassName('.date-pick').value"

$( ".date-pick" ).datepicker({
    onClose: function(dateText, inst) {
        document.getElementsByClassName('.date-pick').value= $(this).val(); 
    }
});