All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
It is disliked to enter the toilet with something on which the mention of Allaah is written. The evidence on this is that Abu Daawood, Ibn Maajah, An-Nasaa'ee, At-Tirmithi, Al-Haakim and Al-Bayhaqi reported that when the Prophet used to enter the toilet he took off his ring [as the Name of Allaah was written on it]. Another narration reads: "The Prophet used to wear a ring on which he engraved 'Muhammad, the Messenger of Allaah’, so when he entered the toilet the used to take it off." Even if there were some criticisms about the above narration, yet some scholars classified it as authentic or sound, like At-Tirmithi and Al-Haakim. Nonetheless, those who are of the view that this narration is weak, did not dislike entering the toilet with something on which the Name of Allaah is written. Anyway, it is better to avoid as much as possible entering dirty places with anything on which the mention of Allaah is written, as a sign of glorifying Allaah and being humble with his Name.
Allaah Knows best.