How to cancle the drop-down for date?

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
Smile Tan
Posts: 4
Joined: Feb 27, 2019 10:59 pm

How to cancle the drop-down for date?

Post by Smile Tan » Feb 28, 2019 1:37 am

I want to input date in format of YYYY/MM/DD. But now it's a drop-down menu. How I can adjust it?
Snipaste_2019-02-28_14-34-35.png
Snipaste_2019-02-28_14-34-35.png (14.17 KiB) Viewed 846 times
Snipaste_2019-02-28_14-34-35.png
Snipaste_2019-02-28_14-34-35.png (14.17 KiB) Viewed 846 times
Attachments
Snipaste_2019-02-28_12-03-16.png
Snipaste_2019-02-28_12-03-16.png (3.5 KiB) Viewed 846 times

cas
Posts: 660
Joined: Mar 11, 2006 11:08 am
Contact:

Re: How to cancle the drop-down for date?

Post by cas » Feb 28, 2019 4:21 am

I suppose you are refering to a custom field?
Then you would need to make it a string field and use the regular expreion field to ensure correct format

Smile Tan
Posts: 4
Joined: Feb 27, 2019 10:59 pm

Re: How to cancle the drop-down for date?

Post by Smile Tan » Jul 26, 2019 4:23 am

cas wrote:
Feb 28, 2019 4:21 am
I suppose you are refering to a custom field?
Then you would need to make it a string field and use the regular expreion field to ensure correct format
You are correct, I am refering to a custom date field.
As you said, string type can solve my question? let me try.

Smile Tan
Posts: 4
Joined: Feb 27, 2019 10:59 pm

Re: How to cancle the drop-down for date?

Post by Smile Tan » Jul 26, 2019 4:46 am

cas wrote:
Feb 28, 2019 4:21 am
I suppose you are refering to a custom field?
Then you would need to make it a string field and use the regular expreion field to ensure correct format
Now I configure it as a string field and configure the regular experion as below: ^(?:(?!0000)[0-9]{4}([-]?)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-]?)0?2\2(?:29))$
It's working normally.
At the same time, do you know some plugins to configure the date as a drop down selection box as attached?
20190726_174407.png
20190726_174407.png (294.71 KiB) Viewed 494 times

cas
Posts: 660
Joined: Mar 11, 2006 11:08 am
Contact:

Re: How to cancle the drop-down for date?

Post by cas » Jul 26, 2019 5:18 am

There are several java scripts available but difficult to activate for custom field.
So you would need to create a plugin for the purpose you are now using a custom field.
Then of course you can make use of such java script

TerranceM
Posts: 6
Joined: Aug 27, 2019 8:55 am
Location: USA
Contact:

Re: How to cancle the drop-down for date?

Post by TerranceM » Oct 11, 2019 12:28 pm

function pad(n){return n<10 ? '0'+n : n}
var date = new Date();
var selectElement = $('<select>'), optionElement;
for (var count =0; count < 90; count++){
date.setDate(date.getDate() + 1);
formattedDate = pad(date.getUTCDate()) + '-' + pad(date.getUTCMonth()+1) + '-' + date.getUTCFullYear();
optionElement = $('<option>')
optionElement.attr('value',formattedDate);
optionElement.text(formattedDate);
selectElement.append(optionElement);
}

You can use the "count" according to your logic.

Post Reply