I have seen many site asking users/ visitors to enter a certain type of numbers before submitting a form to prevent spam attackers.

How does it work actually? Does it really effective? Or is there any other better solutions to avoid spam attacks?

I am trying to look for tutorial or code to write this part for my blog but still can't find any resources yet...

Please let me know if u have any ideas.

Many thanks,