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.
There are four conditions which must be fulfilled in the marriage contract: The bride and bridegroom, the guardian, the two witnesses, and the wording of consent and acceptance; if one of these conditions and pillars are not met, then the marriage is void. For more details, please refer to Fatwa 86755.
As regards the narration which the questioner mentioned, its meaning is that there is no difference between being serious and joking in a marriage contract if it fulfils its conditions and pillars, as it is clear from the wording of the narration.
Allaah Knows best.