Your first problem is with the parsing of the message from the user.
You loop through the string, and it has one of two options, either the character is a dash or it is invalid.
So, ideally, you should be getting an invalid message for the number of a characters in the username before the dash.
You should use String.indexOf to determine where the dash is, and then split the message into it's two parts, and if the result of indexOf is -1 then it is an invalid message.