Yes toenails and fingernails do grow back once they fall off.
However when a nail becomes detached from the nail bed then it cannot reattach but it will fall off or you may have to have it removed and then a new toenail or fingernail will grow back in it's place.
Toenails take at least 18 months to grow back while fingernails take around 6 months.