Reputation: 609
Don't have any idea when my app start in date form to be put the current date.I have a function when a day is clicked to be put in form, but how to do automatically, without clicking on it to be 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);
}
Upvotes: 3
Views: 1978
Reputation: 61
<input id='calendar-input' />
The above didn't work for me. try
<input type="date"/>
Upvotes: 0
Reputation: 339
What you are asking for has more to do with HTML than with full-calendar.
You can achieve this by setting value
attribute of your <input />
tag.
<input id='calendar-input' />
There are two ways to get the seed value for your input field within your javascript code.
1.If you are using moment.js, which is recommended with 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 full-calendar's standard way of getting current date and set it accordingly, in which case it will work for both initial and subsequent selection use getDate method. The method returns current date of the calendar and you can set it exactly like above instead of creating a new moment date object.
Upvotes: 1