if (date.match(/^d{4}-d{2}-d{2}$/) === null) { //it is not a date with format YYYY-MM-DD } else //it is a date with format YYYY-MM-DD