update server.js

Added function that checks whether the move is valid or not. it would be called everytime and would send the message back if the move is invalid