How to Detect Invalid Input ?