"And they found among the inhabitants of Jabesh-Gilead four hundred young virgins who had not known a man by lying with a male" (Judges 21:12). How did they know? They seated them upon the mouth of a barrel of wine: of one no longer a virgin, her scent wafts forth; of a virgin, her scent does not waft forth. But let them pass them before the frontlet [the High Priest's tzitz]? The verse states it is "for acceptance for them" (Exodus 28:38), and not for their punishment. If so, regarding Midian, "and every woman who has known a man by lying with a male, kill" (Numbers 31:17) -- how did they know? They passed them before the frontlet: any whose face turned pale, it was known that her time to be married had come; any whose face did not turn pale, it was known that her time to be married had not yet come.
How the Virgins of Jabesh-Gilead Were Identified
Yalkut Shimoni on Nach 76:3
וימצאו מיושבי יבש גלעד ארבע מאות נערה בתולה אשר לא ידעו משכב זכר. מנא ידעי הושיבון על פי חבית של יין בעולה ריחה נודף בתולה אין ריחה נודף, ונעברינהו לפני ציץ אמר קרא לרצון להם ולא לפורענות. אי הכי במדין וכל אשה יודעת איש למשכב זכר הרוגו מנא ידעי העבירון לפני ציץ כל שפניה מוריקות בידוע שהגיע זמנה להבעל, אין פניה מוריקות בידוע שלא הגיע זמנה להבעל: