processwire-requests icon indicating copy to clipboard operation
processwire-requests copied to clipboard

Make InputfieldDatetime replace comma by dot

Open BernhardBaumrock opened this issue 5 years ago • 6 comments

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

  1. Type 24,12,2019 in a date field
  2. 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...

BernhardBaumrock avatar May 28 '19 11:05 BernhardBaumrock

A bit of context. Keyboards like german ones have a , on the numpad, because it's our decimal point character.

LostKobrakai avatar May 28 '19 12:05 LostKobrakai

Thx for that important note @LostKobrakai !

BernhardBaumrock avatar May 28 '19 13:05 BernhardBaumrock

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!

BernhardBaumrock avatar Sep 02 '23 09:09 BernhardBaumrock

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+".");
    }
  });

BernhardBaumrock avatar Sep 02 '23 09:09 BernhardBaumrock

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).

teppokoivula avatar Sep 03 '23 12:09 teppokoivula

Thx for the correction, @teppokoivula ! Yeah then maybe a setting would be the easiest and best solution.

BernhardBaumrock avatar Sep 03 '23 15:09 BernhardBaumrock