Search code examples
jquerywordpresscontact-form-7

Wordpress Contact From7 selected current day by default


I am new to WordPress and contact form 7. Is there any possibility to get today's date in the contact form 7 datepicker to be selected by default? I have this short-code is [date* all-date id:date-field min:today ]. It didn't work for me. This is what see the user when open the form. enter image description here

i want to be like this :

enter image description here

i try this, but not help me

var date = new Date();
$("#date-field").datepicker({
dateFormat: 'd-M-y'
}).datepicker('setDate', date);

Thanks in advance.


Solution

  • try this:

       var now = new Date(); 
       var day = ("0" + now.getDate()).slice(-2);
       var month = ("0" + (now.getMonth() + 1)).slice(-2);
       var today = now.getFullYear()+"-"+(month)+"-"+(day);
      $('#date-field').val(today);
    $("#date-field").attr("min", today);
    

    for me is working ....