Ähnlich wie bei CheckDate in PHP.
// Funktionsname: checkDatetime // Funktion Einführung: Überprüfen Sie, ob es sich um eine Datumszeit handelt, die Function Function ist. (/d {1,2}): (/d {1,2}): (/d {1,2}): (/d {1,2}) $/; var r = str.match (reg); if (r == null) return; r [6]); if (d.sGetinging ()! = r [1]) return false; if (d.getMonth ()! = r [2]) return false; if (d.getDate ()! False; true;}/** beurteilen Sie das im Eingabefeld eingegebene Datumsformat ist yyyy-mm-dd und das korrekte Datum*/function isdate (sm, mystring) {var reg =/^(/d {4})-(/d {2})-(/d {2}) $/; var st. . dtdate = null; var nyear = parseInt (strdate.substring (0, 4), 10); var nmonth = parseInt (strdate.substring (4, 6), 10); var nday = parseInt (strdate.substring (6, 8), 10); nday) == true) {return null;} dtdate = neues Datum (nyear, nmonth - 1, nday); if (nyear!Das obige einfache Beispiel für JS beurteilt, ob das Datumsformat legal ist, ist der gesamte Inhalt, den ich mit Ihnen teile. Ich hoffe, Sie können Ihnen eine Referenz geben und ich hoffe, Sie können wulin.com mehr unterstützen.