// create a textbox with a check function

function doDate(el, erID)
  {
  var s = el.value;
  var d, m, y;
  var erString = 'data non corretta';
  var len = s.length;

  if (10 == len)
    {
    d = s.substring(0,2);
    m = s.substring(3,5);
    y = s.substring(6,10);
    }

  if (8 == len)
    {
    d = s.substring(0,2);
    m = s.substring(2,4);
    y = s.substring(4,8);
    }

  if (6 == len)
    {
    d = s.substring(0,2);
    m = s.substring(2,4);
    y = '20' + s.substring(4,6);
    }

  if ((checkDate(y,m,d)) || (el.value == ""))
    {
    erString = '';
    document.getElementById('filter').disabled = false;
    if (el.value != "") { el.value = d + '/' + m + '/' + y; }
    } else { document.getElementById('filter').disabled = true; }

  if (document.getElementById) { document.getElementById(erID).innerHTML = erString; }

  if (erString) { if (el.focus) el.focus(); }
  }

function checkDate(y, m, d)
  {
  m = '' + (m-1);
  var checkDate = new Date(y,m,d);
  return (checkDate.getMonth() == m && checkDate.getFullYear() == y);
  }

