Selected current date in Full calendar form
Don't know when my application starts in date form to put the current date. I have a function where the day is clicked to be placed on the form, but how to do this automatically without clicking on it to put there?
$('#calendar').fullCalendar({
sclable: true,
height: 355,
contentHeight: 355,
header: {
right: 'details, today, prev,next',
},
dayClick: function (date) {
var datePicker = date.format('MM/DD/YYYY');
if (!dateToday) {
$('#form_date').val(datePicker);
}
source to share
What you are asking has more to do with HTML than a complete calendar.
You can achieve this by setting an attribute on value
your tag <input />
.
<input id='calendar-input' />
There are two ways to get the initial value for your input field in your javascript code.
1.If you are using moment.js which is recommended with a full calendar, you can do something like this:
const today = moment().format(#formatType);
document.getElementById("calendar-input").value = today;
2.If you want to use the full-calendar standard way of getting the current date and set it accordingly, in which case it will work for both initial and subsequent selection, use getDate . The method returns the current date of the calendar and you can set it exactly as above instead of creating a new date object of the moment.
source to share