• 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: How to merge validation rukes

How to merge validation rukes 11 years 10 months ago #23901

  • khashiz
  • khashiz's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi there,
I want to know if there is a way to combine to validation rule, for example we have "phone number" validation rule and "unique field" validation rule seperately,
by merging theme, eventually we can have "unique phone number" validation rule.

Can anybody help me with this??
The administrator has disabled public write access.

How to merge validation rukes 11 years 10 months ago #23904

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

The following article explains how you can create your own validation rule, in your case you can simply combine the code from both functions:

www.rsjoomla.com/support/documentation/v...alidation-rules.html
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.

How to merge validation rukes 11 years 10 months ago #23906

  • khashiz
  • khashiz's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
would you please be a little more accurate? i'm not too professional in coding,
infact, i don't know how to merge too functions, i want to merge functions "uniquefield" and "phone number"
thank many many times
The administrator has disabled public write access.

How to merge validation rukes 11 years 10 months ago #23940

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can try this approach without modifying the source code:

- make your textbox field required and set the "uniquefield" validation rule
- add the following script in the "Scripts Called On Form Process" area:
$myfield = $_POST['form']['textbox'];
if(!RSFormProValidations::phonenumber($myfield)){
	$invalid[] = RSFormProHelper::getComponentId('textbox');
}

For the script to work you need to replace "textbox" (found 2 times) with your textbox component exact name.

This approach utilizes one validation rule when configuring the component and the calls the function to validate the phone number when the form is processed.

More information on the $invalid method and the scripting areas of RSForm!Pro can be found here:

www.rsjoomla.com/support/documentation/v...602-php-scripts.html
This is not official customer support. To receive your support, submit a support ticket here.
Last Edit: 11 years 10 months ago by adrianp.
The administrator has disabled public write access.

How to merge validation rukes 11 years 8 months ago #24586

  • kevin3
  • kevin3's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I was wondering if there's a way to change the validation message dynamically. For example. I created my own custom validation see below and I would like to modify $data to change to be more informative depending on which of my test failed. So I would like to do

$data = JText::_('THISEMAILALREADYEXIST');

but since the variable $data is not passed by reference I can't do this. Maybe in the next release this variable could be passed by reference or is there another way to do this?


public static function uniqueemail($value, $extra=null, $data=null){
//check if email is valid
$regex = '/[\d!#$%&\'*+.\/=?_`a-z{|}~^-]++@[\d.a-z-]+\.[a-z]{2,6}/i';
if (!preg_match($regex, $value))
{
return false;
}

//check if email is unique
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('count(*)');
$table = $db->quoteName('#__users');
$query->from($table);
$conditions = array(
$db->quoteName('email').' = '.$db->quote(trim($value))
);
$query->where($conditions);
$db->setQuery($query);

$result = $db->loadResult();

if($result){
return false;
}
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!