voodish logo
tweet rss book of faces Linked In

RSForm minimum character for phone | phone validation Joomla

joomla_logo.jpg

How to use a minimum character count for RSForms - making use of the validation extra.

This is especially useful to make sure that customers do not enter unsufficient digits for you to be able to contact them!

1. Open: /components/com_rsform/controller/functions.php
2. Add the following code:

function phone($phone) {
$phone_2 = preg_replace('/[^0-9]+/', '', $phone );
if($phone_2=='') return true;
$len = strlen($phone_2);
if($len == 11 || $len == 14) {
return true;
} else {
return false;
}
}

The above code will require a minimum character count of 11 up to 14, easily changed.

3. Upload your new file, making sure to backup your original version.
You may need to CHOWN your ‘controller’ directory to your FTP user before upload will be allowed.

4. Next, login into your Joomla backend and locate your form manager and for phone ‘Validation Rule’ choose your newly created ‘Phone’ rule from the dropdown.

Working Example

You can check this working on the following URL: www.24-is.co.uk Noting the “Request a Call Back” block near the footer (this is a live site so please only use digits less than 11 to test, thanks).

RSForm minimum character for phone | phone validation Joomla

Related Articles

Comments RSS Feed

2 Comments

  1. rodemila December 17, 2011

    great tutorial !! Thanks for awesome tut..

  2. Go to Top of the page

  3. Madhu Chander April 19, 2013

    Thank you so much. I was looking for this for a website project.

  4. Go to Top of the page

Leave a comment