How to clear out or flush the arduino serial buffer

This seems like the wrong approach to solving your problem. You know when you see the second invalid input, why print out the unwanted message in the first place?