\documentclass[ngerman,a4paper]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{mathptmx}
\usepackage[scaled=.92]{helvet}
\usepackage{courier}
\renewcommand*{\familydefault}{phv}
\usepackage[left=25mm,top=25mm,bottom=10mm,right=10mm]{geometry}
\usepackage{fancyhdr}
\lhead{Firma ABC}\chead{}\rhead{Abteilung XYZ}
\lfoot{}\cfoot{}\rfoot{}
\pagestyle{fancy}
\usepackage{graphicx}
\usepackage{color}
\usepackage[
  pdftex,a4paper=true,colorlinks=true,
  pdftitle={Formular für Schlüsselausgabe},pdfsubject={Zugang},
  pdfauthor={ich},
  pdfpagemode=UseNone,pdfstartview=FitH,
  pagebackref,pdfhighlight={/N}
]{hyperref}
\usepackage[pdftex]{insdljs}
\immediate\pdfobj {
<<
  /WP << /S /JavaScript /JS (willPrint();) >>
  /DP << /S /JavaScript /JS (didPrint();) >>
>>
}
\pdfcatalog{/AA \the\pdflastobj\space 0 R}
\begin{insDLJS}[exaaae]{exaaae}{JavaScript auf Document Level}

// indicate that the function was not yet run
var done = 0;

function colorsPrinting()
{
  this.getField("vorname").fillColor = color.white;
  this.getField("name").fillColor = color.white;
  this.getField("abt").fillColor = color.white;
  this.getField("zeit").fillColor = color.white;
  this.getField("von").fillColor = color.white;
  this.getField("bis").fillColor = color.white;
  this.getField("ht").fillColor = color.white;
  this.getField("e1").fillColor = color.white;
  this.getField("e2").fillColor = color.white;

  this.getField("vorname").strokeColor = color.black;
  this.getField("name").strokeColor = color.black;
  this.getField("abt").strokeColor = color.black;
  this.getField("zeit").strokeColor = color.black;
  this.getField("von").strokeColor = color.black;
  this.getField("bis").strokeColor = color.black;
  this.getField("ht").strokeColor = color.black;
  this.getField("e1").strokeColor = color.black;
  this.getField("e2").strokeColor = color.black;

  this.getField("vorname").textFont = font.Helv;
  this.getField("name").textFont = font.Helv;
  this.getField("abt").textFont = font.Helv;
  this.getField("zeit").textFont = font.Helv;
  this.getField("von").textFont = font.Helv;
  this.getField("bis").textFont = font.Helv;
  this.getField("von").textColor = color.black;
  this.getField("bis").textColor = color.black;
}

function colorsScreen()
{

  var newcolor = [ "RGB", 0.65, 0.79, 0.94];
  this.getField("vorname").fillColor = newcolor;
  this.getField("name").fillColor = newcolor;
  this.getField("abt").fillColor = newcolor;
  this.getField("zeit").fillColor = newcolor;
  this.getField("von").fillColor = newcolor;
  this.getField("bis").fillColor = newcolor;
  this.getField("ht").fillColor = newcolor;
  this.getField("e1").fillColor = newcolor;
  this.getField("e2").fillColor = newcolor;

  this.getField("vorname").strokeColor = newcolor;
  this.getField("name").strokeColor = newcolor;
  this.getField("abt").strokeColor = newcolor;
  this.getField("zeit").strokeColor = newcolor;
  this.getField("von").strokeColor = newcolor;
  this.getField("bis").strokeColor = newcolor;
  this.getField("ht").strokeColor = newcolor;
  this.getField("e1").strokeColor = newcolor;
  this.getField("e2").strokeColor = newcolor;

  this.getField("vorname").textFont = font.HelvB;
  this.getField("name").textFont = font.HelvB;
  this.getField("abt").textFont = font.HelvB;
  this.getField("zeit").textFont = font.HelvB;
  this.getField("von").textFont = font.HelvB;
  this.getField("von").textColor = color.black;
  this.getField("bis").textColor = color.black;
  this.getField("bis").textFont = font.HelvB;
}

function validateTime()
{
  this.delay = true;
  if((event.value == "u") || (event.value == "unbefristet")) {
    this.getField("von").display = display.hidden;
    this.getField("bis").display = display.hidden;
  } else {
    this.getField("von").display = display.visible;
    this.getField("bis").display = display.visible;
    this.getField("von").setFocus();
  }
  this.delay = false;
}

function willPrint()
{
  this.delay = true;
  colorsPrinting();
  this.delay = false;
}

function didPrint()
{
  this.delay = true;
  colorsScreen();
  this.delay = false;
}

// function to run when opening the document
function myFirstJavaScriptFunction()
{
  if(!done) {
    done = 1;
    this.delay = true;
    colorsScreen();
    this.getField("abt").currentValueIndices = 0;
    this.getField("abt").editable = true;
    this.getField("zeit").currentValueIndices = 0;
    this.getField("vorname").setFocus();
    this.delay = false;
  }
}
\end{insDLJS}
\OpenAction{/S /JavaScript /JS (myFirstJavaScriptFunction();)}
\newcommand{\textforlabel}[2]{%
\TextField[name={#1},value={#2},width=7em,align=2,%
bordercolor={1 1 1},readonly=true]{}%
}
\begin{document}
\section*{Anforderung eines Gruppenschl\"{u}ssels}
\begin{Form}
\begin{tabular}{|rl|}
\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{\textbf{Mitarbeiter}}\\
&\\*[-0.9em]\textforlabel{vn}{Vorname:}&%
\TextField[name=vorname,width=20em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Vorname)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte geben Sie Ihren Vornamen in das Textfeld ein.)
}\(\qquad\qquad\)\\
&\\*[-0.9em]\textforlabel{nn}{Name:}&%
\TextField[name=name,width=20em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Name)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte geben Sie Ihren Familiennamen in das Textfeld ein.)
}\(\qquad\qquad\)\\
&\\*[-0.9em]\textforlabel{ab}{Abteilung:}&%
\ChoiceMenu[name=abt,width=20em,popdown=true,combo=true,value=v,%
bordercolor={0.65 0.79 0.94}]{}{%
Verkauf=v,Fertigung=f,Service=s}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Abteilung)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte wählen Sie Ihre Abteilung aus. Falls Ihre Abteilung noch nicht in der Liste enthalten isi, können Sie den Namen Ihrer Abteilung auch eingeben.)
}\(\qquad\qquad\)\\
&\\*[-0.9em]\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{\textbf{Zeitdauer}}\\
&\\*[-0.9em]\textforlabel{z}{Zeitraum:}&%
\ChoiceMenu[name=zeit,width=20em,popdown=true,value=u,%
validate={validateTime();},%
bordercolor={0.65 0.79 0.94}]{}{%
unbefristet=u,befristet=b}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Zeitraum)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte wählen Sie aus, ob der Schlüssel befristet oder unbefristet ausgegeben werden soll. Für eine befristete Ausgabe müssen Beginn und Ende des Zeitraumes angegeben werden.)
}\(\qquad\qquad\)\\
&\\*[-0.9em]\textforlabel{v}{von:}&%
\TextField[name=von,width=10em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\*[-0.9em]\textforlabel{b}{bis:}&%
\TextField[name=bis,width=10em,%
bordercolor={0.65 0.79 0.94}]{}\\
&\\*[-0.9em]\hline
&\\*[-0.9em]\multicolumn{2}{|c|}{%
\textbf{Zu schlie\ss{}ende T\"{u}ren}}\\
&\\*[-0.9em]\textforlabel{th}{Haust\"{u}r:}&%
\CheckBox[name=ht,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (Haustür)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte aktivieren Sie diese Chechbox, um einen Haustürschlüssel zu erhalten.)
}\(\qquad\qquad\)\\
&\\*[-0.9em]\textforlabel{t1}{Etage 1:}&%
\CheckBox[name=e1,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (1. Etage)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte aktivieren Sie diese Checkbox, um einen Schlüssel für die erste Etage zu erhalten.)
}\(\qquad\qquad\)\\
&\\*[-0.9em]\textforlabel{t2}{Etage 2:}&%
\CheckBox[name=e2,width=1.2em,%
bordercolor={0.65 0.79 0.94}]{}~\pdfannot width 20pt {
	/Subtype /Text
	/T (2. Etage)
	/C [0.65 0.79 0.94]
	/Name /Help
	/Contents (Bitte aktivieren Sie diese Checkbox, um einen Schlüssel für die zweite Etage zu erhalten.)
}\(\qquad\qquad\)\\
&\\
\hline
\end{tabular}
\end{Form}
\end{document}
