Praise be to Allah.
A man’s divorce of his wife does not happen by intention alone. If he expresses his intention verbally – or by means of understandable gestures in the case of one who is mute – or by writing, whether on paper or via mobile phone messages or e-mails, all of these mean that the divorce takes effect, provided that that the writing can be proven to be from him, because it is easy to forge messages in these cases.
For more information please see the answer to question no. 36761 and 20660
There is no difference of opinion among the scholars concerning the fact that divorce of one who is serious counts as such.
As for one who is joking, if he clearly utters the words of divorce “You are divorced (talaaq)” verbally, not in writing, then the majority of scholars are of the view that it counts as such. They quoted as evidence the hadeeth narrated by Abu Hurayrah (may Allaah be pleased with him) who said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “There are three matters in which seriousness is serious and joking is serious: marriage, divorce and taking back (one’s wife).” Narrated by Abu Dawood, 2194; al-Tirmidhi, 1184; Ibn Maajah, 2039. Classed as hasan by al-Albaani in Irwa’ al-Ghaleel, 1826.
See also the answer to question no. 44038
With regard to writing the words of divorce, whether the husband writes them on a piece of paper or in a message sent by mobile phone or by e-mail, this does not count as a divorce unless that was his intention.
Shaykh Ibn Baaz (may Allaah have mercy on him) was asked about a man who wrote that his wife was divorced on a piece of paper then gave it to her. He replied:
This divorce does not count for the woman mentioned if he did not intend to divorce her thereby, rather it was just writing or he intended something other than divorce, because the Prophet (peace and blessings of Allaah be upon him) said: “Actions are but by intentions…”
This is the view of a large number of scholars, and some narrated that it is the view of the majority, because writing is a like a metaphor and divorce does not take place by means of metaphors unless it is accompanied by the intention to divorce, according to the more sound of the two scholarly opinions, and unless the writing is accompanied by something which indicates that the intention is divorce, in which case divorce does take place. End quote.
See also the answer to question no. 72291
Based on this, if your husband intended divorce by this writing, then it counts as a divorce. But if he was joking, as you say, and did not intend divorce, then it does not count as a divorce.
Our advice to husbands is to fear Allaah and not to take the rulings of Allaah as a joke or a game. They should realize that divorce destroys families and causes the children to be lost, and it exposes the wife to humiliation and temptation. So they should fear Allaah and preserve their families, and strive to be patient and forbearing before they resort to divorce.
And Allaah knows best.