I don't know much javascript, but that looks extremely error prone to me. How would it behave in different monitor sizes? With zoomed in/out screens? On mobiles, tablets, etc?
And it would still be pretty easy for a cheating script to work cheat your validation!
It's just an example, but zoom should scale both the element coordinates and the mouse coordinates. This sort of validation can be made a lot more elaborate.
And it would still be pretty easy for a cheating script to work cheat your validation!