');
print_r($argument);
print_r('');
}
// if script needs to die() after output, die
if (isset($stop)) die();
}
?>
Zebra_Form, a jQuery augmented PHP library for HTML form building and validation
| Submitted values | ';
foreach ($_POST as $key => $value) {
if (strpos($key, 'name_') !== 0 && strpos($key, 'timer_') !== 0 && strpos($key, 'response_') !== 0)
echo ' |
| ' . $key . ' | ' . (is_array($value) ? '' . print_r($value, true) . ' ' : $value) . ' |
';
}
echo '
';
}
$demos = array(
'A login form' => array('login', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Auto template, labels inside' => 'labels-inside',
'Custom template - divs' => 'divs-custom',
'Custom template - tables' => 'tables-custom',
)),
'A contact form' => array('contact', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Custom template' => 'custom',
)),
'A registration form' => array('registration', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Custom template' => 'custom',
)),
'A reservation form' => array('reservation', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Custom template' => 'custom',
'Auto-fill' => 'autofill-vertical',
)),
'Dependencies' => array('dependencies', array(
'Example 1' => 'example1-custom',
'Example 2' => 'example2-custom',
)),
'File upload' => array('fileupload', array(
'Basic file upload' => 'basic-vertical',
'Basic image upload' => 'basic-image-vertical',
)),
'More rules' => array('validation', array(
'Auto template, vertical' => 'vertical',
)),
);
$current_template = isset($_GET['template']) ? strtolower($_GET['template']) : '';
if (isset($_GET['example']) && is_file('includes/' . $_GET['example'] . '-' . $current_template . '.php')) {
$current_example = strtolower($_GET['example']);
} else {
$current_template = 'vertical';
$current_example = 'login';
}
?>
>
render\(\'includes\/custom\-templates\/.*?\'\)\;/',
);
$replacements = array(
'render(\'path/to/custom-template.php\');',
);
$php_source = preg_replace($patterns, $replacements, $php_source);
?>
In this example, the output is automatically generated by Zebra_Form's render method.
-
try clicking on the submit button without filling the form and then, as you fill the form, to see the
JavaScript validation in action
- for each example, notice how the PHP code of the form remains basically unchanged, despite the template variations
-
disable JavaScript to see the server-side validation in action
-
although in all my examples I use HTML output, you can switch to XHTML output by using the
doctye method
-
try the example in another browser and see that it works, out of the box. including IE6!
Use the links to the left to navigate between examples.
|