01
';
07
08 $myForm = new HTML_QuickForm('EmailFormular', 'POST');
09 $myForm->addElement('header', '', 'Personal Data');
10
11 $myForm->addElement('text', 'textName', 'Surname:');
12 $myForm->addElement('text', 'textFirstname', 'First name:');
13 $myForm->addElement('text', 'textEmail', 'Email:');
14 $myForm->addElement('submit', 'submitButton','Submit data');
15
16 $name =& $myForm->getElement('textName');
17 $name->setMaxLength(30);
18 $name->setSize(30);
19
20 $vname =& $myForm->getElement('textFirstname');
21 $vname->setMaxLength(20);
22 $vname->setSize(30);
23
24 $email =& $myForm->getElement('textEmail');
25 $email->setMaxLength(50);
26 $email->setSize(30);
27
28 // Add validation rules
29 $myForm->addRule('textName', 'Please enter surname', 'required');
30 $myForm->addRule('textFirstname',' Please enter first name', 'required');
31 $myForm->addRule('textEmail', 'Please enter email address', 'required');
32 $myForm->addRule('textEmail', 'Email invalid', 'email');
33 $myForm->addRule('textEmail2', 'Please enter email', 'required');
34 $myForm->addRule('textEmail2', 'Email invalid', 'email');
35
36 // Client-side validation using JavaScript also possible
37 // $myForm->addRule('textEmail', 'Email invalid', 'email', NULL, 'client');
38
39 // Freeze form if validation OK
40 if ( $myForm->validate() )
41 {
42 print 'Thank you! Your data is as follows:';
43 $myForm->removeElement('submitButton');
44 $myForm->freeze();
45 }
46
47
48 // Display form
49 $myForm->display();
50
51 ?>