diff orig/phone.ca.inc ./phone.ca.inc
8c8
<  * @return boolean Returns boolean FALSE if the phone number is not valid. 
---
>  * @return string Returns a message explaining what is wrong in the phone number or '' if the phone number is ok. 
29,30c29,32
<   // return true if valid, false otherwise
<   return (bool) preg_match($regex, $phonenumber); 
---
>     if (preg_match($regex, $phonenumber)) {
> 	return '';
>     }
>     return '"%value" is not a valid North American phone number<br>North American Phone numbers should only contain numbers and + and - and ( and ) and spaces and be like 999-999-9999. Please enter a valid ten-digit phone number with optional extension.';
diff orig/phone.fr.inc ./phone.fr.inc
8c8
<  * @return boolean Returns boolean FALSE if the phone number is not valid. 
---
>  * @return string Returns a message explaining what is wrong in the phone number or '' if the phone number is ok. 
15c15
<   	return false; 
---
>   	return '"%value" is not a valid French phone number<br>French phone numbers should only contain numbers and spaces and be like 99 99 99 99 99';
21c21
< 	return true;
---
> 	return '';
50c50
< }
---
> }
diff orig/phone.module ./phone.module
19a20
>     'it_phone' => array('label' => t('Italian Phone Numbers')),
33c34
<         '#default_value' => isset($field['phone_country_code']) ? $field['phone_country_code '] : '',
---
>         '#default_value' => isset($field['phone_country_code']) ? $field['phone_country_code'] : '',
41c42
<       if ($field['type'] == 'fr_phone'){ 
---
>       if (array_key_exists($field['type'], phone_field_info())) { 
46,50d46
<       if ($field['type'] == 'ca_phone'){ 
<       	$columns = array(
<         	'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
<       	);
<       }      
88c84
<       'field types' => array('fr_phone', 'ca_phone'),
---
>       'field types' => array(phone_field_info()),
120c116
<       'field types' => array('fr_phone', 'ca_phone'),
---
>       'field types' => array(phone_field_info()),
187,192c183,193
<     	        if ($field['type'] == 'fr_phone') { 
< 	  	  $node_field[0]['value'] = format_phone_number('fr', $node_field[0]['value'], $field);
< 	        }
<     	        if ($field['type'] == 'ca_phone') { 
< 	          $node_field[0]['value'] = format_phone_number('ca', $node_field[0]['value'], $field);
< 	        }
---
>                 if (array_key_exists($field['type'], phone_field_info())) { 
> 		    list($countrycode, $suffix) = explode('_', $field['type']);
> 		    $phonenumber = trim($node_field[0]['value']);
> 
> 		    $format_phone_function = 'format_'. $countrycode . '_phone_number';  	
> 		    include_once('./'. drupal_get_path('module', 'phone') . '/phone.'. $countrycode . '.inc');
> 				
> 		    if (function_exists($format_phone_function)) {
> 			$node_field[0]['value'] = $format_phone_function($phonenumber, $field);
> 		    }
> 		}
204,208c205,221
<               if ($field['type'] == 'fr_phone' && !valid_phone_number('fr', $item['value'])) {
<                 form_set_error($field['field_name'],t('"%value" is not a valid French phone number<br>French phone numbers should only contain numbers and spaces and be like 99 99 99 99 99', array('%value' => $item['value'])));
<               }
<               if ($field['type'] == 'ca_phone' && !valid_phone_number('ca', $item['value'])) {
<                 form_set_error($field['field_name'],t('"%value" is not a valid North American phone number<br>North American Phone numbers should only contain numbers and + and - and ( and ) and spaces and be like 999-999-9999. Please enter a valid ten-digit phone number with optional extension.', array('%value' => $item['value'])));
---
>                 if (array_key_exists($field['type'], phone_field_info())) { 
> 		    list($countrycode, $suffix) = explode('_', $field['type']);
> 		    $phonenumber = trim($item['value']);
> 
> 		    $valid_phone_function = 'valid_'. $countrycode . '_phone_number';  	
> 		    include_once('./'. drupal_get_path('module', 'phone') . '/phone.'. $countrycode . '.inc');
> 			
> 		    if (function_exists($valid_phone_function)) {
> 			    $res = $valid_phone_function($phonenumber);
> 		    }
> 		    else {
> 			$res = 'I\'m unable to test if "%value" is a valid phone number (' . $valid_phone_function . ' missing)'; 
> 		    }
> 		    if ($res != '') {
>     		        form_set_error($field['field_name'],t($res, array('%value' => $item['value'])));
> 		    }
> 		}
213d225
<       break;
215,274d226
< }
< 
< /**
<  * Verification for Phone Numbers.  
<  *
<  * @param string $countrycode
<  * @param string $phonenumber
<  * @return boolean Returns boolean FALSE if the phone number is not valid.  
<  */
< function valid_phone_number($countrycode, $phonenumber) {
< 
<   $countrycode = trim($countrycode); 
<   $phonenumber = trim($phonenumber);
< 
<   if ($countrycode == 'fr' 
<   	|| $countrycode == 'ca') { 
< 	
<         //drupal_set_message('langue = ' . $countrycode, 'error');
< 
<   	$valid_phone_function = 'valid_'. $countrycode . '_phone_number';  	
<   	include_once('./'. drupal_get_path('module', 'phone') . '/phone.'. $countrycode . '.inc');
<   	
< 	if (function_exists($valid_phone_function)) {
< 	    return $valid_phone_function($phonenumber);
< 	}
<   }
<   else {
<   	return false; 
<   }
< }  
< 
< /**
<  * Verification for Phone Numbers.  
<  *
<  * @param string $countrycode
<  * @param string $phonenumber
<  * @return boolean Returns boolean FALSE if the phone number is not valid.  
<  */
< function format_phone_number($countrycode, $phonenumber, $field) {
< 
<   $countrycode = trim($countrycode); 
<   $phonenumber = trim($phonenumber);
< 
<   if ($countrycode == 'fr' 
<   	|| $countrycode == 'ca') { 
< 	
<         //drupal_set_message('langue = ' . $countrycode, 'error');       
< 
<   	$format_phone_function = 'format_'. $countrycode . '_phone_number';  	
<   	include_once('./'. drupal_get_path('module', 'phone') . '/phone.'. $countrycode . '.inc');
<   	
< 	if (function_exists($format_phone_function)) {
< 	    return $format_phone_function($phonenumber, $field);
< 	}
<   }
<   else {
<   	return false; 
<   }
< }  
< 
