It is narrated from Sayyiduna Ka'b bin Ujrah (may Allah be pleased with him): "We were present with the Prophet (peace and blessings be upon him), and he (peace and blessings be upon him) asked (a man): 'O so-and-so, have you married?' He said: 'No.' Then he (peace and blessings be upon him) asked me: 'Have you married?' I said: 'Yes.' He (peace and blessings be upon him) asked: 'Did you marry a virgin or a thayyib (a widow or divorcee)?'" (Then he mentioned the complete hadith.)
I say: The basis of this hadith is found in the two Sahihs and other books of hadith, from the narration of Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both).