Nice idea but easily circumvented.
There was a bit of uproar a couple a months ago, because Google started evaluating javascript when displaying search results (see
here).
So I guess javascript is no longer ideal. I can only think of two other methods
I'd probably go with CAPTCHA...