I see at least three issues with claiming that answer as wrong: first, correctness is essential (in the true sense) in mathematics, and therefore should not be carelessly dismissed in front of the student. Second, students should not be made to believe that guess-and-try is always inappropriate, but rather to understand that it won't always work. Finally, in this particular example the approach chosen is arguably (at least from the student's perspective) simpler than the one expected by the professor. Invalidating a "simpler" approach might give the student the impression that you always need to take the complicated route (ie, "math is hard") when the opposite is true.
My own take on this example would be to give (partial?) marks, with a lengthy comment of the type "fair enough, in this case, but what about if you wanted to solve x^3 =7? Your method wouldn't work, then!". Alternatively, if you don't want to give marks, it should be justified at length by rules clearly explained before the exam, while acknowledging the correctness of the approach.