• 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: Cummulative validation

Cummulative validation 14 years 11 months ago #7531

I have several fields each of which represent a quantity of certain item. What is the simplest way to make a check on zero amount in these fields?

For example, I have:

field 1: 0
field 2: 0
field 3: 0

I need to display the validation message until the sum of these three fields less than 1. I can check with JS and display an simple alert, but this is so lame. I'd probably prefer a PHP-script, a validation function maybe.
The administrator has disabled public write access.

Re:Cummulative validation 14 years 11 months ago #7544

OK, I managed to solve the problem myself. In the case, anybody else needs it, here's a solution:

1. Create a summary field.
2. Write a simple JS which will calculate the amount from other fields.
3. Add a function in /components/com_rsform/controller/validation.php:
function zeroorder($param)
{
	preg_match("/(\d+)/s", $param, $matches);	
	if ($matches[1] > 0) return true;
}

4. Choose "zeroorder" as validation rule for summary field and type validation message.
5. Enjoy.

This may not be applicable for any situation, but the idea is pretty clear.
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!