From everything I saw during our visit, there is no specific dress code requirement to visit Montserrat. However, for the abbey and the church, you should wear more respectable clothing (so no super short shorts, mini skirts, or tank tops) or you might be asked to leave. Make sure to wear comfortable shoes and always pack a sweater as it's much colder in the mountains in Montserrat than it is in Barcelona.