RobinHerbots/Inputmask

Two-character time marker AM or PM doesn't work

franatdorlet opened this issue · 6 comments

  • Describe the bug:

    When we configure a time marker with two character 'mm/dd/yyyy h:MM:ss TT' and we set the value '12/31/2024 1:23:03 AM' , the value appears in the input is '12/31/2024 1:23:03 A0' and IsValid return false also.

    Examples 1:
    const element = document.getElementById('myinput');
    const inputMask = Inputmask({
    alias: 'datetime',
    inputFormat: 'mm/dd/yyyy h:MM:ss TT',
    prefillYear: false,
    placeholder: '_',
    showMaskOnHover: false
    }).mask(element);
    inputMask.setValue('12/31/2024 1:23:03 AM');

    Examples 2:
    Inputmask.isValid('12/31/2024 1:23:03 AM', {
    alias: 'datetime',
    inputFormat: 'mm/dd/yyyy h:MM:ss TT',
    prefillYear: false,
    placeholder: '_',
    showMaskOnHover: false,
    })

  • OS: Windows

  • Browser: Chrome

  • Inputmask version: 5.0.9-beta.70

Thanks a lot, for your hard work :)

I can confirm this issue. As a temporary workaround, use the escapeCharacter (default is \) for the time marker like this:
inputMask.setValue('12/31/2024 1:23:03 A\\M');.

The workarround only works for setValue but not for isValid.

As another temporary workaround, you can remove the last character from your string (which will be the M) and validate against mm/dd/yyyy h:MM:ss T format.

@franatdorlet ,

Fixed in 5.0.9-beta.72

@RobinHerbots Amazing work !!!!. When is it going to be published ?