Page 1 of 1

setting a default time in a date and time field

Posted: 12 May 2020
by Roo
Is there a way I can default a time within a time/date field (say 00:01) within the forms designer?

I have a problem where people neglect to full the time in and as such the start and end date fields are reduced by one day.

Thanks

Re: setting a default time in a date and time field

Posted: 12 May 2020
by mnikitina
Hello Roo,

You can try out something like this. The below code checks hours and minutes and if it's set to midnight, it sets minutes to be equal 10.

Code: Select all

fd.field('Date').change(function(){
  var hours = fd.field('Date').value()[1];
  var minutes = fd.field('Date').value()[2];

  if(hours == '12 AM' && minutes == '00') {
  	console.log('wrong');
  	var date = fd.field('Date').value();
  	//set minutes to be equal 10
  	date.splice(2, 1, '10');
  	fd.field('Date').value(date);
  }
});