PHP表单验证 a_Form 2.7.5 发布

jopen 13年前
     Zebra_Form 是一个 PHP 类用于简化表单的创建和数据验证。    <br />    <img title="zibra.gif" border="0" alt="zibra.gif" src="https://simg.open-open.com/show/d700ecd1ffae4e57479f58b04865fa97.gif" width="48" height="48" />    <br /> 示例代码:    <br />    <pre class="brush:php; toolbar: true; auto-links: false;"><?php  // include the Zebra_Form class  require 'path/to/Zebra_Form.php';    // instantiate a Zebra_Form object  $form = new Zebra_Form('form');    // the label for the "email" field  $form->add('label', 'label_email', 'email', 'Email');    // add the "email" field  // the "&" symbol is there so that $obj will be a reference to the object in PHP 4  // for PHP 5+ there is no need for it  $obj = & $form->add('text', 'email', '', array('autocomplete' => 'off'));    // set rules  $obj->set_rule(array(      // error messages will be sent to a variable called "error", usable in custom templates      'required'  =>  array('error', 'Email is required!'),      'email'     =>  array('error', 'Email address seems to be invalid!'),  ));    // "password"  $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'),  ));    // "remember me"  $form->add('checkbox', 'remember_me', 'yes');  $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me');    // "submit"  $form->add('submit', 'btnsubmit', 'Submit');    // validate the form  if ($form->validate()) {      // do stuff here  }  // auto generate output, labels above form elements  $form->render();  ?></pre>Zebra_Form 2.7.5 发布了,该版本修复了单页中多个表单时会导致除第一个表单外的所有表单的客户端验证失效;修复了选择分组无法通过验证的问题;修复了 textarea 不支持 placeholder 的问题;修复了基于 display:none 和 visibility:hidden 属性的元素不进行客户端验证的问题。另外该版本将 Zebra_Transform 插件独立开来,需要单独下载。    <br />    <br /> 项目地址:    <a href="/misc/goto?guid=4958190659106783367" target="_blank">http://stefangabos.ro/php-libraries/zebra-form/</a>