What is the ruling on one who swore on the Mushaf (Qur’an) when he was not in a state of purity?
Question

                Is an oath sworn three times on the Mushaf (Qur’an) by touching it from the outside valid, or is it not acceptable? 

Please note that I was compelled to do it and I was not in a state of purity.
Praise be to Allah.
    Firstly: 
In 
    order for an oath to be valid, it is not essential that the one who is 
    swearing the oath should place his hand on the Mushaf or swear three times. 
    If he swears by Allah once, without placing his hand on the Mushaf, his oath 
    is valid, and that is sufficient. 

    Ibn Qudaamah (may Allah have mercy on him) said: Ibn al-Mundhir said: We did 
    not find anyone who stated that one should swear on the Mushaf. Ash-Shaafa‘i 
    said: I saw them swearing on the Mushaf by way of affirming the oath, and I 
    saw Ibn Maazin, when he was a qaadi (judge) in San‘aa’, making people affirm 
    their oaths by swearing on the Mushaf. His companions said: He would make 
    them affirm it by bringing the Mushaf, because it contains the words and 
    names of Allah, may He be exalted. But this is something additional to the 
    instructions of the Messenger of Allah (blessings and peace of Allah be upon 
    him) regarding the swearing of oaths, and to what was done by the 
    Rightly-Guided Caliphs and their qaadis, without any evidence or proof for 
    that. The practice of the Messenger of Allah (blessings and peace of Allah 
    be upon him) and his companions should not be abandoned in favour of the 
    practice of Ibn Maazin or anyone else.

    End quote from al-Mughni (19/214) 
It 
    says in Fataawa al-Lajnah ad-Daa’imah (vol. 1, 23/48): In many court 
    cases, a man swears an oath by putting his hand on the Mushaf. Is this 
    correct, or is it sufficient for the oath just to say “By Allah”? 

    The committee replied: it is sufficient for the person to swear by Allah 
    without placing his hand on the Mushaf. End quote. 

    Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said: 

    Swearing an oath is not permissible except by Allah, may He be exalted, or 
    by one of His attributes. … If a person swears by Allah, may He be glorified 
    and exalted, then there is no need to bring the Mushaf so that he may swear 
    on it, for swearing on the Mushaf is something that was not done by the 
    righteous earlier generations; it was not done at the time of the Prophet 
    (blessings and peace of Allah be upon him) or at the time of the Sahaabah. 
    Even after the Mushaf was compiled, they did not swear on the Mushaf. Rather 
    a person would swear by Allah, may He be glorified and exalted, without 
    swearing on the Mushaf. 

    End quote from Fataawa Noor ‘ala ad-Darb by Ibn ‘Uthaymeen 

    See also the answer to question no. 98194

    Secondly: 

    There is nothing wrong with a person swearing on the Mushaf if he is 
    required to do so. 
It 
    says in Qaraar Majma‘ al-Fiqh al-Islami: 

    Placing the hand on the Mushaf when swearing an oath is not required in 
    order for the oath to be valid, but it is permissible, if the judge sees 
    fit, to confirm the solemnity of the oath and so as to deter the oath-taker 
    from lying. End quote. 

    But it is stipulated that the person who wants to touch the Mushaf at the 
    time of swearing the oath should be in a state of purity. 
If 
    the oath is sworn without touching the Mushaf, in the sense that the 
    individual swears the oath before the Mushaf and points to it, but without 
    touching it, then there are no reservations about that and it is not 
    required to be in a state of purity in order to point to the Mushaf or swear 
    on it without touching it. A similar concession is   also granted if it is 
    carried in a holder or touched with a barrier (such as a piece of cloth) and 
    the like. In that case there is nothing wrong with it, in sha Allah, 
    especially if there is a need for that or it is too difficult for him. So if 
    he is in a situation that requires him to do that, or he is afraid that he 
    will be badly thought of or that people will speak ill of him, and he seeks 
    to ward that off from himself – in that case we hope that there will be 
    nothing wrong with it, in sha Allah. 

    And Allah knows best.