Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

Custom Validation

Welcome, Guest
Username Password: Remember me

Custom Validation
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Custom Validation

Custom Validation 2 years, 8 months ago #7645

  • Coldice
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
I have tried to add the validation to the "validation.php" but it not works why?
Do I need to do something more?

Thanks.

PS: I want the PHONE-Validation. So if you could make it for me that would be good because I don't think my regex code worked.

Re:Custom Validation 2 years, 8 months ago #7653

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

You can refer to the following article where you can find a function for telephone validation:

www.rsjoomla.com/customer-support/forum/...one-number-help.html

Regards!

Re:Custom Validation 2 years, 8 months ago #7662

  • Coldice
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Hi!

function phone($phone)
{
if( $phone=='' ) return true;
if(eregi('^((?[2-9]{1}[0-9]{2})?|[0-9]{3,3}[-. ]?)[ ]?[0-9]{3,3}[-. ]?[0-9]{4,4}$', $phone ))
return true;
else
return false;
}


I try this code. But should I change $phone with $param?

Re:Custom Validation 2 years, 8 months ago #7665

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

You can use the code as it is. Just follow the steps in this article:

www.rsjoomla.com/customer-support/docume...alidation-rules.html

The new function being "function phone".

Regards!

Re:Custom Validation 2 years, 8 months ago #7668

  • Coldice
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Thanks, but how should the regex code look like if I want phone number like this:
12345678 - 8 numbers??

EDIT:
The code doesn't work, can you please make the code work for me with 8 numbers like above?

The name of the phone field is: Mobiltelefon
Last Edit: 2 years, 8 months ago by Coldice.

Re:Custom Validation 2 years, 7 months ago #7678

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

Here is the correct validation code for a telephone number with 8 numbers:

 
function phone($phone)
{
if($phone=='' || !numeric($phone) || (strlen($phone)!=8)) return false;
if(eregi('^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$', $phone ))
return false;
else
return true;
}
 


It doesn't matter what the name of the field is. Note this is a validation rule so the name of the function will appear in the "Validation Rule" drop down.

Also if anyone else will want to use this function, but with other telephone number length (or without number length limit) please change this line:

 
if($phone=='' || !numeric($phone) || (strlen($phone)!=8)) return false;
 


To:

 
if($phone=='' || !numeric($phone)) return false;
 


Or just change the limit from 8 to what number would you want.

Regards!
Last Edit: 2 years, 7 months ago by bogdanc.

Re:Custom Validation 2 years, 7 months ago #7685

  • Coldice
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
Thanks.
But that's for US number. I'm from Norway and we have number like this:
12345678

So how should the regex be like?
Should it be:
if(eregi('^[0-9]{3}-[0-9]{3}-[0-9]{2}$', $phone ))


For number like this:
123-456-78 ??

EDIT:
Doesn't work at all.
Last Edit: 2 years, 7 months ago by Coldice.

Re:Custom Validation 2 years, 7 months ago #7699

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

Use this script for numbers like: 123-456-78

 
function phone($phone)
{
list($number1,$number2,$number3)=split("-",$phone,3);
if($phone=='' || strlen($phone)!=10 || !(is_numeric($number1)) || !(is_numeric($number2)) || !(is_numeric($number3)) || strlen($number3)!=2) return false;
if(ereg('^([0-9]{4})-([0-9]{4})-([0-9]{3})$', $phone))
return false;
else
return true;
}
 


This script can be customized for all kinds of Telephone Numbers.

Regards!

Re:Custom Validation 1 year ago #12427

  • KevenM
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
Where would I install this script? Tried putting it in the scripts section (on load, and on process), but neither worked.

Also, with this script in place, what do we set the standard validation rule to?

Re:Custom Validation 6 hours, 1 minute ago #0

Hello,
This is an automatically generated message.
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 wish to receive our 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: http://www.rsjoomla.com/support-policy.html.

Thank You!
PLEASE NOTE: This topic is NOT locked and you can add replies to it. Other users are free to reply as well. This message has been generated by a bot and has no effect on the topic whatsoever.
  • Page:
  • 1
Moderators: alex, alexp, octavian, bogdanc, andreic
Time to create page: 1.39 seconds
Feedback