表单构建器类

时间:2011-04-27 15:45:42

标签: php oop class forms

我正在使用PHP表单构建器类(http://code.google.com/p/php-form-builder-class /)而我正在尝试验证电话号码?我使用的是1.4x版本。

您如何为电话号码提供验证或添​​加单独的规则?

我在这里尝试过尝试:

// Define the phone regex
define( 'FILTER_PHONE', '/^\(?[0-9]{3}\)?|[0-9]{3}[-. ]? [0-9]{3}[-. ]?[0-9]{4}$/' ); 
// if took this line from the example
if(isset($_POST["cmd"]) && in_array($_POST["cmd"], array("submit_0"))) { 
      // If submitted
      if ( !empty( $_GET['cmd'] ) ) {

                if( !empty( $_GET["Phone"]  ) ) { 
                        $form->errorMsg = preg_match(stripslashes($_GET["Phone"]), 
FILTER_PHONE); 
                }                 
      } 
 } 

1 个答案:

答案 0 :(得分:1)

这个问题的答案是升级到上周末刚刚发布的PHP form builder class的最新2.0x分支:Download