function check_date_eu(textbox){
  //script configuration - Please set the wanted time range
  var year_range_begin = '1930';
  var year_range_end = '2040';

  //  contains the given date-string
  var Date;

  //  contains the length of the given date-string
  var date_length;

  //  contains the number of days of the month
  var month_length;

  //  These contain the day,month and year of the given date string after
  //  format correction
  var Day,Month,Year;

  //  number of points in date-string
  var point_count = 0;

  //  positions of points in date-string
  var point_positions = new Array;

  //  the new formated date is filled in here
  var correct_date_temp = new Array;

  //  start position of the year in the date-string
  var year_start_pos = 0;

  Date = textbox.value;
  date_length = Date.length;

  if(Date != ""){
    for(var str_pos = 0;str_pos < date_length; str_pos++){
      if(Date.charAt(str_pos)<"0" || Date.charAt(str_pos)>"9"){
        if(Date.charAt(str_pos,1)=='.'){
          point_count++;
          if(point_count <= 2){
            point_positions[point_positions.length] = str_pos;
          }
        }
        else{
          alertbox(textbox);
          return false;
        }
      }
    }
    if(point_count!=2){
      alertbox(textbox);
      return false;
    }
    //case 1 day-length = 1
    if(point_positions[0] == 1){
      correct_date_temp[correct_date_temp.length] = "0";
      correct_date_temp[correct_date_temp.length] = Date.substr(0,1);
      correct_date_temp[correct_date_temp.length] = ".";
      //month-length = 1
      if(point_positions[1] == 3){
        correct_date_temp[correct_date_temp.length] = "0";
        correct_date_temp[correct_date_temp.length] = Date.substr(2,1);
        correct_date_temp[correct_date_temp.length] = ".";
        year_start_pos = 4;
      }
      //month-length = 2
      else if(point_positions[1] == 4){
        correct_date_temp[correct_date_temp.length] = Date.substr(2,2);
        correct_date_temp[correct_date_temp.length] = ".";
        year_start_pos = 5;
      }
      //point at wrong position
      else{
        alertbox(textbox);
        return false;
      }
    }
    //case 2 day-length = 2
    else if(point_positions[0] == 2){
      correct_date_temp[correct_date_temp.length] = Date.substr(0,2);
      correct_date_temp[correct_date_temp.length] = ".";
      //month-length = 1
      if(point_positions[1] == 4){
        correct_date_temp[correct_date_temp.length] = "0";
        correct_date_temp[correct_date_temp.length] = Date.substr(3,1);
        correct_date_temp[correct_date_temp.length] = ".";
        year_start_pos = 5;
      }
      //month-length = 2
      else if(point_positions[1] == 5){
        correct_date_temp[correct_date_temp.length] = Date.substr(3,2);
        correct_date_temp[correct_date_temp.length] = ".";
        year_start_pos = 6;
      }
      //point at wrong position
      else{
        alertbox(textbox);
        return false;
      }
    }
    //year-length = 1
    if(date_length - year_start_pos == 1){
      correct_date_temp[correct_date_temp.length] = "200";
      correct_date_temp[correct_date_temp.length] = Date.substr(year_start_pos,1);
    }
    //year-length = 2
    else if(date_length - year_start_pos == 2){
      if(Date.substr(year_start_pos,2)<=30){
        correct_date_temp[correct_date_temp.length] = "20";
        correct_date_temp[correct_date_temp.length] = Date.substr(year_start_pos,2);
      }
      else{
        correct_date_temp[correct_date_temp.length] = "19";
        correct_date_temp[correct_date_temp.length] = Date.substr(year_start_pos,2);
      }
    }
    //year-length must be 4
    else if(date_length - year_start_pos == 4){
      correct_date_temp[correct_date_temp.length] = Date.substr(year_start_pos,4);
    }
    else{
      alertbox(textbox);
      return false;
    }
    Date = correct_date_temp.join("");
    textbox.value = Date;

    if (Date.length==10 && Date.substring(2,3)=="." && Date.substring(5,6)=="."){
      Day = parseInt(Date.substr(0,2),10);
      Month = parseInt(Date.substr(3,2),10);
      Year = parseInt(Date.substr(6,4),10);
    }
    else{
      alertbox(textbox);
      return false;
    }
    if (Month==4 || Month==6 || Month==9 || Month==11){
      month_length=30;
    }
    else if (Month==1 || Month==3 || Month==5 || Month==7 || Month==8 || Month==10 || Month==12){
      month_length=31;
    }
    else if(Month==2 && Year%4==0 && Year%100!=0 || Year%400==0){
      month_length=29;
    }
    else if(Month==2 && Year%4!=0 || Year%100==0 && Year%400!=0){
      month_length=28;
    }
    if (Day>=1 && Day<=month_length && Month>=1 && Month<=12 && Year>=year_range_begin && Year<=year_range_end){
      return true;
    }
    else{
      alertbox(textbox);
      return false;
    }
  }
}

function alertbox(textbox){
  alert('' + textbox.value + ' ist kein gültiges Datum');
  textbox.value='';
  this.focus();
  textbox.focus();
}
