I made this so only messages starting with ‘/msg’ or ‘/logout’ will submit.
But, users can still send messages! Is something wrong with my code?
if ((msg.indexOf("/msg") != 0) && (msg.indexOf("/logout") != 0))
{
return;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
indexOfwill return -1 if theStringis not found otherwise it will return the index found which is >= 0So your test have to be:
or