Search code examples
wordpresscontact-form-7

How to display the today date in contact form 7 without datepicker


i want to display the current date (today date the date off submission of the form) in field date in contact form 7 without choosing it using the datepicker,i want also to disable the datepicker if it's possible.please help.


Solution

  • You have to add this script.

    <script>
    jQuery(function ($) {
       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);
       $('#MydatePicker').val(today);
       $("#MydatePicker").attr("min", today);
    });
    </script>
    
    [date* your-date class:required id:MydatePicker] 
    

    Please check it.