• 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: Telephone # validation field

Telephone # validation field 13 years 10 months ago #14067

Does anyone have a piece of code to share that I can add to the field validation list. I understand how to add the code but I'm not good enough to write that code.
The administrator has disabled public write access.

Re:Telephone # validation field 13 years 10 months ago #14092

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 745
  • Thank you received: 66
Hello,

You can refer the following forum post for an example on this topic:

www.rsjoomla.com/customer-support/forum/...dation-.html?limit=6
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Re:Telephone # validation field 13 years 8 months ago #14540

Try adding this function to the validation.php (components/com_rsforms/validation.php)

And then select 'phone' from the validation rule dropdown in the validations tab when adding / editing a new field to your form.



function phone($phone) {
if(RSFormProValidations::numeric($phone, null) && strlen($phone) == 10)
return true;
else
return false;
}
The administrator has disabled public write access.

Re: Telephone # validation field 13 years 3 months ago #16178

  • learnthrusong
  • learnthrusong's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 26
  • Thank you received: 3
bob.standish wrote:
Does anyone have a piece of code to share that I can add to the field validation list. I understand how to add the code but I'm not good enough to write that code.

Hi there,

I use the following for validating UK telephone numbers... Simply copy/paste this into the validation.php file, ensuring it's inside of the 'outer' curly braces, i.e. inside of the class, 'class RSFormProValidations'.
function ukTelNo($telUK){
        	 if (eregi('((\+44\s?\(0\)\s?\d{2,4})|(\+44\s?(01|02|03|07|08)\d{2,3})|(\+44\s?(1|2|3|7|8)\d{2,3})|(\(\+44\)\s?\d{3,4})|(\(\d{5}\))|((01|02|03|07|08)\d{2,3})|(\d{5}))(\s|-|.)(((\d{3,4})(\s|-)(\d{3,4}))|((\d{6,7})))', $telUK))
        	 return true;
        	 else
        	 return false;
}

Hope this helps!

Gez
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!