Advertisement
nirodhasoftware

zebra1

Sep 28th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2.  
  3. // include the Zebra_Form class
  4. require 'path/to/Zebra_Form.php';
  5.  
  6. // instantiate a Zebra_Form object
  7. $form = new Zebra_Form('form');
  8.  
  9. ?>
  10.  
  11. <!-- must be in strict mode! -->
  12. <!DOCTYPE html>
  13.  
  14. <html>
  15.  
  16.     <head>
  17.  
  18.         <title>Zebra_Form Example</title>
  19.  
  20.         <meta charset="utf-8">
  21.  
  22.         <!-- load Zebra_Form's stylesheet file -->
  23.         <link rel="stylesheet" href="path/to/zebra_form.css">
  24.  
  25.         <!-- load jQuery -->
  26.         <script src="path/to/jquery.js"></script>
  27.  
  28.         <!-- load Zebra_Form's JavaScript file -->
  29.         <script src="path/to/zebra_form.js"></script>
  30.  
  31.     </head>
  32.  
  33.     <body>
  34.  
  35.         <?php
  36.  
  37.         // the label for the "email" field
  38.         $form->add('label', 'label_email', 'email', 'Email');
  39.  
  40.         // add the "email" field
  41.         $obj = $form->add('text', 'email', '', array('autocomplete' => 'off'));
  42.  
  43.         // set rules
  44.         $obj->set_rule(array(
  45.  
  46.             // error messages will be sent to a variable called "error", usable in custom templates
  47.             'required'  =>  array('error', 'Email is required!'),
  48.             'email'     =>  array('error', 'Email address seems to be invalid!'),
  49.  
  50.         ));
  51.  
  52.         // "password"
  53.         $form->add('label', 'label_password', 'password', 'Password');
  54.  
  55.         $obj = $form->add('password', 'password', '', array('autocomplete' => 'off'));
  56.  
  57.         $obj->set_rule(array(
  58.  
  59.             'required'  => array('error', 'Password is required!'),
  60.             'length'    => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
  61.  
  62.         ));
  63.  
  64.         // "remember me"
  65.         $form->add('checkbox', 'remember_me', 'yes');
  66.  
  67.         $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me');
  68.  
  69.         // "submit"
  70.         $form->add('submit', 'btnsubmit', 'Submit');
  71.  
  72.         // validate the form
  73.         if ($form->validate()) {
  74.  
  75.             // do stuff here
  76.  
  77.         }
  78.  
  79.         // auto generate output, labels above form elements
  80.         $form->render();
  81.  
  82.         ?>
  83.  
  84.     </body>
  85.  
  86. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement