That is a good practice no matter what the laws are. I've always kept our veggie (now herb) garden fenced and have been thankful on so many occasions when we've been greeted by cows, horses, llamas, etc. munching on the front lawn. We usually just push them into the front field and wait for the owner to spot them. We once had a very nice looking steer for about a month before his owner finally came for him.