Updating the IsValidCharacter function to check for specific inputs.