user3239696
user3239696

Reputation: 3

Date picker issue on form submit

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());

Upvotes: 0

Views: 141

Answers (1)

kavetiraviteja
kavetiraviteja

Reputation: 2208

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(); 
    }
});

Upvotes: 1

Related Questions