Sometimes the prophet Muhammad wore shoes for prayer. At that time the foundation of the mosque was not covered with carpet, but it was stone and soil. So when you pray on the ground you do not have to take off your shoes. If your shoes are dirty please remove them before praying. The following sentences prove this.
From Abu Maslamah: Anas ibn Malik asked, "Does Messenger pray if you put on your shoes?" Yes "(Bukhari, prayer, 24; Tirmidhi, prayer, 181)
Abdullah Ibn Masood said: Of course we saw a letter using prayers for his shoes. (Abu Dawud, prayer, 88; Ibn Majah, stage prayer, 66)
Abu Saeed Hadley said: Before praying with friends, Messenger took off his shoes and set it aside. People who saw this also took off his shoes. When Messenger finished praying, he asked: "Why are you taking off your shoes?" They said, "As you did this, we removed them. "If you get dirty in the mosque, please check your shoes and clean them, then pray with shoes" (Abu Dawud, Prayer, 88)
Shaddad ibn Aws tells from his father. Messenger said:
Sentences such as "Do you do this" and "Pray with shoes" represent freedom, not order. The scholars say that they can pray with their shoes as long as they are clean. You can pray barefoot. This is optional. It is understood from many other stories that messenger can pray on bare feet or in shoes. (Reference: Abu Dawood, Prayer, 88)
In addition to laundry, there are other rules that apply to people entering the mosque, even though they do not want to pray there. It is prohibited to wear shoes in the place of the chapel carpet. Even though they can not be used for prayers, some mosques also do not allow shoes to be worn elsewhere. Muslims require that believers wear discreet clothes. Therefore, men and women must comply with this rule when participating in a mosque (although the mosque does not necessarily force the rule). Men should wear loose and comfortable clothes to the mosque, these clothes can not show the shape of the body. Likewise, women coming to the mosque should wear loose clothes, shirts, pants that cover the wrists and ankles, and cover their heads with scarves. Many Muslims are wearing special occasions to pray, Middle Eastern costumes related to Arabic Muslims, regardless of their ethnic background
When you enter the mosque, please take off your shoes or wear sandals. Entering a mosque should be done first with a right foot, and one person sends blessings to Muhammad and his family. After entering the mosque, two rak'a should be executed. Mosque people should speak quietly, should not speak loudly, so he or she does not disturb people to pray. For Friday prayers, it recommends that you wear beautiful clothes and perfumes. Women entering the mosque are not disturbed by the Quran and Sunnah, but rather are hindered by regulations on how women should act in mosques. Mosques can be isolated both temporally and spatially. However, in some Muslim countries, women entering the mosque are not welcomed, and the mosque can be closed to women through local rules and customs. In Turkey, women can easily enter any mosque