To check validity of date

Ask input from user in form of ddmmyy. Does if loop can check the validity of the date key in by user??