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;
}
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;
}
Copyright © 2021 Jogjafile Inc.
indexOfwill return -1 if theStringis not found otherwise it will return the index found which is >= 0So your test have to be:
or