user2790911 user2790911 - 6 months ago 47
jQuery Question

Robin Herbots Inputmask Date Limits

Do I understand correctly that Robin Herbots Inputmask only works for dates between 1900 and 2099?
I want to use it to help the user enter dates before 1900 and be sure about the format. I don't particularly care if the user enters a leap year when there wasn't a leap year, or thinks that there are 31 days in September. Thanks.

Answer

In line 33 of /js/jquery.inputmask.date.extensions.js - simply edit the years by century match from (19|20) to whatever you need so for years 1700 - 2299 so..

'y': { //basic year
  validator: "(17|18|19|20|21|22)\\d{2}",
  cardinality: 4,
  prevalidator: [
    { validator: "[12]", cardinality: 1 },
    { validator: "(17|18|19|20|21|22)", cardinality: 2 },
    { validator: "(17|18|19|20|21|22)\\d", cardinality: 3 }
  ]
}
Comments