Jul 7, 2021
0
Level 4
Date picker not working Safari (Mac)
onInput(e) {
const DATE_FORMAT = {
null: new RegExp("^$"),
full: new RegExp(
"^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"
),
"month-year": new RegExp("^(0?[1-9]|1[012])(\/([0-9]{4})?)?$"),
"year-only": new RegExp("^[0-9]{4}$")
};
let text = e || "";
//console.log(text)
const test = Object.entries(DATE_FORMAT).find(regexp => {
this.catchType = regexp[1].test(text);
//console.log(this.catchType)
if (regexp[1].test(text)) {
return regexp[0];
} else {
//console.log('s')
this.dateError =
"Date Must be Valid Format EX: (DD/MM/YYYY OR MM/YYYY OR YYYY)";
}
});
if (test) {
this.format = test[0];
this.date = text;
this.birthDate = text;
this.dateAutoSlashes(e);
}
this.$forceUpdate();
},
dateAutoSlashes(e) {
if (e.inputType === "deleteContentBackward") return;
if (this.date.length === 2) {
this.date = this.date + "/";
}
if (this.date.length === 5 && parseInt(this.date.substr(3)) <= 12) {
this.date = this.date + "/";
}
},
if i enter 18/04/2009 safari show me 18 jan 2009
Any one know what is wrong?
Please or to participate in this conversation.