How to deal with 2 digit year when we have mask setup for 4 digit.
Connor9220 opened this issue · comments
Connor9220 commented
When someone keys in a date. mm/dd/yyyy format Everything is good.. but, we have some people, who will just key in mm/dd/yy and they tab or save.. the system ends up with something like this. 06/06/23__
Is there a way to make it append '20' suffix to the year when we're requesting a 4 digit year if the field looses focus? Some other parts of our application just tells them it's a bad date.. but, it should be smart enough to know if you key in a 2 digit year, even though we're asking for a 4, that it can convert it to 20xx
Robin Herbots commented
You can add some extra logic like this. (Use the onBeforeWrite option)
onBeforeWrite: function (e, buffer, caretPos, opts) {
if (e) {
switch (e.type) {
case "blur":
// DO YOUR LOGIC HERE
// manipulate the buffer if needed, like adding 20 befoire the year part
return {
refreshFromBuffer: true,
buffer: buffer
};