Putting a form behind JavaScript can be a useful way to hide it from spam bots. It may make it more difficult for them to find the form in the first place and it also means the spam bot would have to use resources to get JavaScript to render the form. Spam bots are about quantity, not quality, and even a modest barrier like this can put them off. I tend to combine this with a honey trap and time check and together they work very effectively.
This jQuery code takes a div
and turns it into a form
.
$('div.fake-form').each(function() {
$(this).replaceWith($('<form action="/contact/" method="post">' + this.innerHTML + '</form>'));
});
Then have something like this in your markup:
<div class="fake-form">
<!-- Your form goes here -->
</div>
