Fixed a couple bugs

If an invalid date is typed date becomes false and date.getTime() causes an exception.
If an invalid value was typed selecting a date doesn't work.