How to cancle the drop-down for date?
Moderators: Developer, Contributor
How to cancle the drop-down for date?
I want to input date in format of YYYY/MM/DD. But now it's a drop-down menu. How I can adjust it?
- Attachments
-
- Snipaste_2019-02-28_12-03-16.png (3.5 KiB) Viewed 7686 times
Re: How to cancle the drop-down for date?
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
Then you would need to make it a string field and use the regular expreion field to ensure correct format
Re: How to cancle the drop-down for date?
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?
Re: How to cancle the drop-down for date?
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
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
Re: How to cancle the drop-down for date?
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.
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.