我正在使用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);
}
}
}