lundi 28 août 2017

Trouble restricting Pikaday input

I have the following ember-pikaday input:

    = pikaday-input [
      value=person.birth_date
      class="form-control"
      placeholder="MM/DD/YYYY"
      format="MM/DD/YYYY"
      yearRange=dateYearRange
      readonly=(is-readonly disabled)
      onSelection=(action "setField" person "birth_date") ]

There's a problem with this input in that I can type something like "asdf" into it. I want it only to accept valid dates.

I found a keyboardInput option in ember-pikaday's configuration documentation so I tried it like this:

    = pikaday-input [
      keyboardInput=false
      value=person.birth_date
      class="form-control"
      placeholder="MM/DD/YYYY"
      format="MM/DD/YYYY"
      yearRange=dateYearRange
      readonly=(is-readonly disabled)
      onSelection=(action "setField" person "birth_date") ]

It had no apparent effect. I also tried a couple of the other configuration options and they didn't seem to work as expected, either.

I thought maybe I was just editing the wrong file or something. But I removed some of the existing configuration options as a test, and that had an effect, as expected. So I'm really confused about why some options seem to work and some don't.

Any ideas on how to move forward with this problem would be greatly appreciated. I'm open to any solution that forces the Pikaday input to contain a valid date.




Aucun commentaire:

Enregistrer un commentaire