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: 28 Feb 2019, 03:59

How to cancle the drop-down for date?

Post by Smile Tan »

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 7605 times
Snipaste_2019-02-28_14-34-35.png
Snipaste_2019-02-28_14-34-35.png (14.17 KiB) Viewed 7605 times
Attachments
Snipaste_2019-02-28_12-03-16.png
Snipaste_2019-02-28_12-03-16.png (3.5 KiB) Viewed 7605 times
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

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

Post by cas »

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: 28 Feb 2019, 03:59

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

Post by Smile Tan »

cas wrote: 28 Feb 2019, 09:21 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: 28 Feb 2019, 03:59

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

Post by Smile Tan »

cas wrote: 28 Feb 2019, 09:21 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 7253 times
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

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

Post by cas »

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: 26
Joined: 27 Aug 2019, 13:55
Location: USA

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

Post by TerranceM »

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