converting the text box value to date on change event with a two digit year is being considered as the current year

I am clearing out my text box if the user enters a date equal to the current date. 
I have a text box to take a date (06-13-1999) / (06/13/1999) formats. Before I finish entering my 4 digit year since I am using an on Change event Javascript native date function is converting the 2 digit year to current year and clearing my text box.

So I am currently using a condition by splitting the date entered date.split('/')[2] .length = 4 which seems to be tedious since now I need two split functions to allow different date formats.

```
if (dob.split('/')[2].length == 4 || dob.split('-')[2].length == 4)
{
    ndob = new Date(dob);
    ndob = formatdate(ndob);
}

```

Is there any other way of handling this on change event