processwire-requests
processwire-requests copied to clipboard
Make InputfieldDatetime replace comma by dot
Short description of the enhancement
It would be great if the InputfieldDatetime replaced input of "comma" to a "dot". This would make it a lot faster to input dates on keybords with a number pad.
Optional: Steps that explain the enhancement
- Type 24,12,2019 in a date field
- You'll get 24.12.2019
Current vs. suggested behavior
Current: You'll get 24122019 or you need a second hand to type the dot.
Why would the enhancement be useful to users?
It's the little things that make the everyday experience great or not great...
PS: I've tried to implement it myself in InputfieldDatetime.js but a simple .on('keyup change') did not work. There is something going on before that event fires that prevents input of commas in such fields...
A bit of context. Keyboards like german ones have a ,
on the numpad, because it's our decimal point character.
Thx for that important note @LostKobrakai !
This is how german numpads look like, so you see it would be really a great improvement to be able to use the comma instead of the dot.
I don't think that it could have any drawbacks as I don't think that a real comma is ever needed in a datetime field? Or maybe it would be good to have a config setting for replacing comma with dot.
I have this feature in use with a custom JS in my own CRM and I've input so many datetimes since 2019 so I can really say that it is of huge help!

This is the solution that I have in place since 2019:
// replace input of commas to dots for easy num-block input
// this will input 1.1.2020 when you type 1,1,2020
$(document).on('keyup', 'input.InputfieldDatetimeDatepicker', function(e) {
var code = e.keyCode || e.which;
var $field = $(this);
if(code === 110 || code === 188) {
var val = $field.val();
$field.val(val+".");
}
});
I don't think that it could have any drawbacks as I don't think that a real comma is ever needed in a datetime field?
Datetime inputfield can be configured to use a date such as "September 3, 2023", so it would either need to be a configurable option, or inputfield settings would need to be taken into account (check if input format includes literal comma).
Thx for the correction, @teppokoivula ! Yeah then maybe a setting would be the easiest and best solution.