In order for a marriage to be valid, it is stipulated that it be witnessed by two Muslim witnesses of good character, because the Prophet (peace and blessings of Allaah be upon him) said: “There is no marriage except with a wali (guardian) and two witnesses of good character. Narrated by al-Bayhaqi from the hadeeth of ‘Imraan and ‘Aa’ishah; classed as saheeh by al-Albaani in Saheeh al-Jaami’ no. 7557.
With regard to the witness, it is stipulated that he be male, an adult and of sound mind. The testimony of a child, woman or insane person is not valid.
It says in Sharh Muntaha’l-Iraadaat (2/648): The marriage contract cannot be done except with the witness of two males who are adults, of sound mind, able to speak and hear, Muslims – even if the wife is a dhimmi (Jew or Christian living under Muslim rule) – and of good character, even if it is only outwardly. End quote.
It says in al-Mawsoo’ah al-Fiqhiyyah (41/296): The Hanafis, Maalikis, Shaafa’is and Hanbalis are of the view that the two witnesses to marriage must be mukallaf i.e., adults of sound mind. The testimony of an insane person is not acceptable, according to scholarly consensus. And a child cannot be a witness, because the Prophet (peace and blessings of Allaah be upon him) said: “Bring two witnesses from among your men,” because children are not among those who can give testimony. End quote.
The presence of witnesses is one of the conditions of marriage being valid, whether the marriage contract is done verbally or in writing, in the event that the husband or wali is unable to speak.
Based on that, it is not valid for children to be witnesses to the marriage contract.
And Allaah knows best.