0
我正在使用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);
}
}
}
我d使用PEAR的Validate類和它的各個國家子類。 – ceejayoz 2011-04-27 15:52:50