| 
<?phpdefine('LANGUAGE','en');
 include 'class.SimpleFormValidator.php';
 
 $form = new SimpleFormValidator(__DIR__.'/example.form.php');
 if(!empty($_GET)){
 if($form->validate($_GET)){
 $form->triggerCustomError('test[email][weird_name_just_to_prove_it_works]','Validation successful, custom error triggered.');
 }
 }else{
 $form->setValues(array(
 'test' =>
 array (
 'email' =>
 array (
 'weird_name_just_to_prove_it_works' => '[email protected]',
 'repeated' => '[email protected]',
 ),
 'type_email' => '[email protected]',
 'password' => 'asdf',
 'repeat_password' => 'asdf',
 ),
 'a_radio_button' => 'något annat',
 'foo' =>
 array (
 'bar' => 'some_value',
 ),
 'a_list' => 'ett konstigt värde',
 'area' => 'ett konstigt värde',
 ));
 }
 
 ?><!DOCTYPE html>
 <html lang="en">
 <head>
 <meta name="charset" content="UTF-8">
 <meta name="author" content="Jonas Earendel">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta name="description" content="PHP Form validation example.">
 <title>An example - SimpleFormValidator</title>
 <style>
 label{
 padding-top:1em;
 display: block;
 font-weight: bold;
 }
 .error {
 border:2px solid black;
 }
 .sfv{
 color:red;
 }
 </style>
 </head>
 <body>
 <h1>An example</h1>
 <p>
 In this example I use GET instead of POST. This makes it easier to manipulate values and trigger errors.
 </p>
 <p>
 I also have words in Swedish to test unicode characters, as well as a weird variable structure.
 </p>
 <p>
 (The form has the <b>novalidate</b> attribute, to ensure server side validation only.)
 </p>
 <form action="/example.php" method="get" novalidate>
 <?php $form->html(); ?>
 
 </form>
 </body>
 </html>
 
 |