
<!--------------------------------------------------------------------->
function ist_Schaltjahr(j) {  
    return ((j % 4 == 0) && ((j % 100!= 0) || (j % 400 == 0)));  
    }
<!--------------------------------------------------------------------->

function falsches_datum(this_handle) {  
    t1 = "Ungültiges Datumsformat: >> " + this_handle.value + " <<\n\n";  
    t2 = "Erlaubte Trennzeichen: ', . / -' \n\nJahreszahl: 4stellig (1980-2020)\n\n";  
    t3 = "z.B.:    01-12-2000        1.12.2000      31/12/2000     17,7,2000";
	alert(t1 + t2 + t3 + "\n\n[" + this_handle.name + "]");  this_handle.value='';  this_handle.focus(); 
}  

<!--------------------------------------------------------------------->
function check_date(this_handle){  
    datumstring = this_handle.value;  
    if (datumstring == "") {
       return true;
    } 

<!--- Leeres Feld ist gueltig --->    
<!--- Formale Pruefung --->  
text = datumstring.replace(/[^0-9.,-\/]/g,""); 

<!--- Ungueltige Zeichen entfernen --->  
zahlen = text.split(/[ ,.\-\/]/);    

<!--- In tt mm jjjj auftrennen --->  
    if (zahlen.length != 3) {
        falsches_datum(this_handle);  
        return false;
    }
  
<!--- Bereichspruefung --->  
mtage = new Array (0,31,28,31,30,31,30,31,31,30,31,30,31);
tag   = zahlen[0]*1; 

<!--- String in Zahl wandeln --->  
monat = zahlen[1]*1;  
jahr  = zahlen[2]*1;  
if (ist_Schaltjahr(jahr)){ 
    mtage[2] = 29}; 

<!--- Februar bei Schaltjahr korrigieren --->
if ((jahr  < 1980) || (jahr  >2020))   {
    falsches_datum(this_handle); 
    return false;
}  

if ((monat <    1) || (monat >  12))   {
    falsches_datum(this_handle); 
    return false;
    }  
if ((tag   <    1) || (tag >  mtage[monat])) {
    falsches_datum(this_handle); 
    return false;
    }
 
<!--- Ausgabe formatieren --->  
if (tag   < 10){
    tag   = "0" + tag   
    }  

<!--- Formatierung 2stellig --->  
    if (monat < 10){
    monat = "0" + monat; 
    }

<!--- Formatierten Eingabewert ins Formular zurueckschreiben --->  
this_handle.value = (tag + "." + monat + "." + jahr);

<!--- Formatierten 'D_'-Wert ins Formular zurueckschreiben --->  
db_date = ( jahr + "-" + monat + "-" + tag);  
eval( "document." + this_handle.form.name + ".D_" + this_handle.name +
  ".value = '" + db_date + "'"); 
return true;  
}
<!--- Wenn die Routine bis hier gekommen ist, dann ist alles OK --->}
<!------------------------------------------------------------------->

function check_form(){   
    if (check_date(document.datum_test_form.Datum_1)   == false){
       return false
       };     

    if (check_date(document.datum_test_form.Datum_2)   == false){
       return false
       };       
    return true; 
    }
