I try to have a Date Mask as MM/DD/YYYY appear as soon as user click on a textbox using only JavaScript or Typescript with using jQuery or any template. I have this JavaScript code:
function DateFormat() {
var date = this.value;
if (date.match(/^\d{4}$/) !== null) {
this.value = date + '-';
} else if (date.match(/^\d{4}\-\d{2}$/) !== null) {
this.value = date + '-';
}
}
<input type="text" onclick="DateFormat();">
but I am getting this error:
Cannot read property 'match' of undefined
I would like to mask appeard like --/--/--when I click on the text box.