<?php
require_once 'HTML/QuickForm.php';

// QuickForm Version anzeigen
print 'PEAR::HTML_QuickForm Version ';
print HTML_QuickForm::apiVersion() . '<br/><br/>';


$myForm     = new HTML_QuickForm('EmailFormular', 'POST');
$myForm->addElement('header', '', 'Pers&ouml;nliche Angaben');

$myForm->addElement('text',   'textName',    'Name:');
$myForm->addElement('text',   'textVorname', 'Vorname:');
$myForm->addElement('text',   'textEmail',   'E-Mail:');
$myForm->addElement('submit', 'submitButton','Daten senden');

$name =& $myForm->getElement('textName');
$name->setMaxLength(30);
$name->setSize(30);

$vname =& $myForm->getElement('textVorname');
$vname->setMaxLength(20);
$vname->setSize(30);

$email =& $myForm->getElement('textEmail');
$email->setMaxLength(50);
$email->setSize(30);


// Validierungsregeln hinzufuegen
$myForm->addRule('textName',   'Bitte Name angeben',      'required');
$myForm->addRule('textVorname','Bitte Vorname angeben',   'required');
$myForm->addRule('textEmail',  'Bitte E-Mail angeben',    'required');
$myForm->addRule('textEmail',  'Bitte E-Mail ung&uuml;ltig', 'email');
$myForm->addRule('textEmail2', 'Bitte E-Mail angeben',     'required');
$myForm->addRule('textEmail2', 'Bitte E-Mail ung&uuml;ltig', 'email');


// Auch moeglich, clientseitige Validierung mit JavaScript
// $myForm->addRule('textEmail', 'E-Mail ungueltig', 'email', NULL, 'client');

// Falls Validierung OK, Formular einfrieren
if ( $myForm->validate() )
{
   print 'Vielen Dank! Ihre Angaben sehen wie folgt aus:';
   $myForm->removeElement('submitButton');
   $myForm->freeze();
}


// Formular anzeigen
$myForm->display();

?>
