I want to set the today's date to the DateTime control of sharepoint. My code is:

$(document).ready(function () {
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1; //January is 0!

    var yyyy = today.getFullYear();
    if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} var today = dd+'/'+mm+'/'+yyyy;
    var today= mm+'/'+dd+'/'+yyyy;  
    $( "td.ms-dtinput > input[id$='DateTimeFieldDate']" ).val= today;   

But I am not getting the value inserted in the DateTime conrol's text box. What am I missing?


you can't set value like this

$("DateTimeControlID").val = "date";  

you have to set value like this

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.