We don’t know here what you’ve tried, what you are having difficulty with, and what exactly you’re trying to do (by valid, do you mean any valid date? Or is there a specific rule about what is and is not a valid date? In what timezone? etc). A single screenshot doesn’t really help anyone here understand any of that.
I assume this is part of the application you mention in your other post. If I can give you one piece of advice: just use a maintained and widely-used library for dates, dates are a nightmare to work with and you shouldn’t really be writing your own logic for anything non-trivial, it’s generally a waste of time. The date functionality in JavaScript’s standard library is very basic, use something better, i.e.