You are viewing limited content. For full access, please sign in.

Question

Question

date field default value to be tomorrow date

asked on September 18, 2023

How to assign the date field default value to be the date after current date?

0 0

Replies

replied on September 18, 2023

Classic or v11?  Classic, you can set the value property using moment tool in Javascript.

0 0
replied on September 18, 2023 Show version history

For Classic:

$(document).ready(function() {
  const holdTomorrow = moment().add(1, "days").format("L");
  $("#q44 input").prop('value', holdTomorrow);
});

https://momentjs.com/

0 0
replied on September 18, 2023

It is the classic designer

I have put the default value as current date as shown below and it is in a table. So how will I make the default value date which is in a table to be tomorrow date? Thank you.

0 0
replied on September 19, 2023 Show version history

Given a table definition like this...

Which looks like this...

This JavaScript will initialize the date fields to tomorrow in the dd/mm/yyyy format.

$(document).ready(function() {
// Moment.js Javascript date utilities
// See "Included CSS and JavaScript Libraries" under Forms in Admin Guide
  const holdTomorrow = moment().add(1, 'days').format('D/M/YYYY');
// Change value of all initial Child DOB fields
  $("#q44 input").prop('value', holdTomorrow);


// Change value for newly added children
  $("#q40>a").click( function() {
    $("#q44 input").last().prop('value', holdTomorrow);
  });
});

like this...

 

Check out these links

https://momentjs.com/

https://api.jquery.com/

Have fun, Jim.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.