Contact Form 7 Phone Number Validation

========================= contact-form-7/modules/text.php

insert this code:

wpcf7_add_shortcode( 'digit', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'digit*', 'wpcf7_text_shortcode_handler', true );

after this:

wpcf7_add_shortcode( 'email*', 'wpcf7_text_shortcode_handler', true );

insert this code:

if ( 'digit' == $type || 'digit*' == $type )
$class_att .= ' wpcf7-validates-as-digit';

after this:

if ( 'text*' == $type || 'email*' == $type )
$class_att .= ' wpcf7-validates-as-required';

insert this code:

add_filter( 'wpcf7_validate_email*', 'wpcf7_text_validation_filter', 10, 2 );
add_filter( 'wpcf7_validate_digit*', 'wpcf7_text_validation_filter', 10, 2 );

after this:

add_filter( 'wpcf7_validate_email', 'wpcf7_text_validation_filter', 10, 2 );

insert this code:


if ( 'digit' == $type || 'digit*' == $type ) {
if ( '' == $_POST[$name] ) {
$result['valid'] = false;
//$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_required' );
$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
} elseif ( '' != $_POST[$name] && ! is_telnum( $_POST[$name] ) ) {
$result['valid'] = false;
//$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_digit' );
$result['reason'][$name] = wpcf7_get_message( 'invalid_digit' );
}
}

after this if code:

if ( 'email' == $type || 'email*' == $type ) {
if ( 'email*' == $type && '' == $_POST[$name] ) {
$result['valid'] = false;
$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_required' );
} elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
$result['valid'] = false;
$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_email' );
}
}

================== contact-form-7/includes/functions.php to add the error message for the telephone number validation.

insert this code:

'invalid_digit' => array(
'description' => __( "There is a field that sender is needed to fill in with numbers", 'wpcf7' ),
'default' => __( 'Please fill the required field with numbers.', 'wpcf7' )
)

after this code:

'invalid_required' => array(
'description' => __( "There is a field that sender is needed to fill in", 'wpcf7' ),
'default' => __( 'Please fill the required field.', 'wpcf7' )
),

===========================wp-includes/formatting.php and create a new function

function is_telnum($telnum)
{
//$regexp = '/^[0-9\+\-]{7,}$/';
//$regexp = '/^[0-9]{1,}/';//numeric
$regexp = '/^[0-9\+\-\)\(\d\s]{7,}$/';

if(preg_match($regexp, $telnum))
return true;
else
return false;
}

=========

Your Phone [digit* text-123]

Free WordPress Plugins List

Below Plugins are some of the free plugins i used in my projects

Contact Form Contact Form7

Sitemap Plugin wp-sitemap,simple sitemap(good)

Support buddypress in any themes BuddyPress Template Pack

Creating/editing,renaming User roles role manger(Best)

Lightbox image Lightbox 2

Best Customizing content Slider Featured articles Lite

Twitter Messages Twitter for WordPress extended

Weather Plugin WPwunderground

Ad manager wp insert

Subscription Subscribe2

youtube Video slider(carousel) CDOKAY TV

Category List In Hierarchical Order inWordpress edit post page(backend) Category Checklist Tree

Video slider with flash Ultimate carousel free Video Gallery, pluginswp.com
To use the slider inside template insert the following code

<?php
$tag= array('[ultimate_carouselfree 1 /]','1');
$output=ultimate_carouselfree_video_render($tag);
echo $output;
?>