Is it OK just to vent the bathroom exhaust to the attic with a roof cap?

Magicman asked:

I have two bathrooms and when contemplating replacing the the exhaust fans in each, I noticed that these two fans are just vented to the attic. Their isn’t a vent to the outside, but the attic does have a roof cap…if that matters any.

I just want to do it correctly, but I don’t want to do a ton of extra work if it’s alright to just replace the fans. Plus, I don’t want to put a hole in my roof.

Also, how would I vent this if I have too?

%Attic Exhaust Fans%

Thanks in advance!