Zebra_Form 是一個 PHP 類用於簡化表單的創建和數據驗證。
示例代碼:
<?phprequire 'path/to/Zebra_Form.php';$form = new Zebra_Form('form');$form->add('label', 'label_email', 'email', 'Email');$obj = & $form->add('text', 'email', '', array('autocomplete' => 'off'));$obj->set_rule(array( 'required' => array('error', 'Email is required!'), 'email' => array('error', 'Email address seems to be invalid!'),));$form->add('label', 'label_password', 'password', 'Password');$obj = & $form->add('password', 'password', '', array('autocomplete' => 'off'));$obj->set_rule(array( 'required' => array('error', 'Password is required!'), 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),));$form->add('checkbox', 'remember_me', 'yes');$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me');$form->add('submit', 'btnsubmit', 'Submit');if ($form->validate()) { }$form->render();?>