Keyboard Input with Webshim's Date Picker

847 Views Asked by At

I am using the webshims library to support older browsers better with more modern features. While the date picker works great with the mouse I seem to be having problems using it from the keyboard. The easiest way to see this is visit the demo page. I am using Firefox since it doesn't have date support.

Without making any modifications try to type in a date. I can enter numbers but I cannot enter a "/". If you enable the placeholder it even suggests the slash. I tried leaving out the separator or using "-" (which it lets me type) but when the form submits I get no value.

How are you supposed to enter a date via the keyboard?

For bonus points is it possible to allow the date picker to not enforce a format? I have backend code that can parse a wide variety of date formats. So they can use the date picker if they wish but if they type something in then whatever they type in is sent onto the server without modification.

2

There are 2 best solutions below

0
On BEST ANSWER

Try this.This works for '/' format..

 $.webshims.formcfg = {
      en: {
        dFormat: '/',
        dateSigns: '/',
        patterns: {
          d: "mm/dd/yy"
        }
      }

    };
    webshims.activeLang('en');
2
On

It appears that there is an issue with the locale settings. From what I can tell, there is a form config attribute called dateSigns that gets set in the locale settings.

The solution for me was to go to file shims/combos/5.js and look for a chunk of code having dateSigns in it. I found the relevant one for US English around line 1750, which looks like this:

    if(!formcfg['en-US']){
        formcfg['en-US'] = $.extend(true, {}, formcfg.en, {
            date: {firstDay: 0},
            patterns: {d: "mm/dd/yy"},
            dateSigns: '-',
          dFormat: "/",
            meridian: ['AM', 'PM']

        });
    }

I updated the dateSigns line to

dateSigns: '/',

It is a horrible hack, and there must be a way to set this as a configuration, or at least get the real locale settings to handle this. But I didn't manage to in the limited time I have available. But maybe this will help you. It works for me.