Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contact Form 7: Set default date to today

How do I set the default date to today, using Contact Form 7?

The minimum date can be set easily with min:today. When you click on a datepicker you can choose dates from today.

But the default date (before picking) is not today's date. The date is displayed like 2016/mm/dd or whatever date format.

like image 806
jer23jk Avatar asked Jun 18 '16 05:06

jer23jk


1 Answers

Yes, I added a 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);
  $('#datePicker').val(today);
$("#datePicker").attr("min", today);
});
</script>

And than call it in:

[date* your-date class:required id:datePicker] 
like image 122
jer23jk Avatar answered Oct 21 '22 10:10

jer23jk