All depends on how well you clean it and the thickness of the carpet!
Bacteria thrive in little nooks and crannies, so make sure you clean it very thoroughly. I would use a bleach based carpet cleaner, but be careful of discolouring the carpet!!
I did my best, but over the years and houses you can see the place afterwards, but I would imagine with little left it would biodegrade and they'd have little to live off after a while. Toothbrushes lost their germs after a few days, I only hope the carpet does, especialy after stain removal!
there is a product you can put straight on the carpet from pet shops in a liquid form that breaks down the acids in "pet messages" that household cleaners can not, and bleach is unacceptable full stop. Remember that an animals scent is different from our own and can still smell it after cleaning, if you dont get rid of it 100% the animal associates that area as a place to go for other "messages" I can't remember what it is called but I saw it on "it's me or the dog" on channel 4