Function ValidaCI(CI : String) : Boolean;
var
flat : Boolean;
fecha : TDateTime;
begin
flat := True;
if (Length(CI) <> 11) then
begin
flat := False;
Application.MessageBox('No. Carnet de Identidad incompleto.' + #13 + 'Rectifique por favor.','SAF', MB_ICONERROR);
end
else if StrToInt(Copy(CI,3,2)) > 12 then
begin
flat := False;
Application.MessageBox('Error en el mes del Carnet de Identidad.' + #13 + 'Rectifique por favor.','SAF', MB_ICONERROR);
end
else
begin
try
fecha := StrToDate(Copy(CI,5,2)+ '/' + Copy(CI,3,2) + '/' + Copy(CI,1,2));
except
flat := False;
Application.MessageBox('La fecha de nacimiento no es válida.' + #13 + 'Rectifique por favor.','SAF', MB_ICONERROR);
end;
end;
Result := flat;
end;