chrisl-921fb74d
chrisl-921fb74d

Reputation: 23120

Form builder class

I'm using the PHP form builder class (http://code.google.com/p/php-form-builder-class/) and i'm trying to validate phone numbers? I'm using version 1.4x .

How would you provide validation for phone number or add seperate rules?

I've tried an attempt here:

// 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); 
                }                 
      } 
 } 

Upvotes: 0

Views: 697

Answers (1)

chrisl-921fb74d
chrisl-921fb74d

Reputation: 23120

The answer to this question is to upgrade to the latest 2.0x Branch of the PHP form builder class that was just released this past weekend: Download

Upvotes: 1

Related Questions