• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Regex Validation Phone Number

Regex Validation Phone Number 10 years 5 months ago #27950

  • studio41
  • studio41's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 1
Hi
I want to validate a phone number but the default phone number validation in RSForm Pro is not suitable for UK numbers.
I want the textbox to only allow numbers and allow either 6 numbers or 11 numbers (phone number and phone number with area code respectively).

I figure the best way to do this is by using Regex as the validation rule but I have no idea how to type out what I want as Regex.

Any ideas?
The administrator has disabled public write access.

Regex Validation Phone Number 10 years 4 months ago #28030

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Following the steps described in the following article : http://www.rsjoomla.com/support/documentation/view-article/75-custom-validation-rules.html add the code below in the validation.php :
	public static function customPhone($value)
	{
		if (preg_match("/^[0-9]{6}$/",$value) || preg_match("/^[0-9]{11}$/",$value)){
		return true;
		}
		return false;
	}

This code will check if the value inserted in the field is numeric and is 6 or 11 characters long.

Please note that on the next update this validation rule will be overwritten, don't forget to back it up
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!