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

Conditional validation 10 years 7 months ago #28962

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
I'm looking a way to validate values based on a selection of another field. Let me explain:

User selects a product (fieldname: extra1)
User has to select a size (fieldname: maat1)
User has to select an amount (fieldname aantal1)

When a user selects a product but forgets to select the size and/or amount there should be a notification that a selection of those two is required.

Hope someone can help.

Thanks,
Hans
The administrator has disabled public write access.

Conditional validation 10 years 7 months ago #28977

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
Simply set the fields as 'required' and you're done. You can do so in Components >> RSForm!Pro >> Manage Forms >> edit your form >> Components >> edit a field >> Validations >> set "Required" to "Yes". You can read more about RSForm!Pro's select fields in the following articles:

www.rsjoomla.com/support/documentation/v...le/827-dropdown.html

www.rsjoomla.com/support/documentation/v...-checkbox-group.html

www.rsjoomla.com/support/documentation/v...829-radio-group.html

You can edit the error message in Components >> RSForm!Pro >> Manage Forms >> edit your form >> Properties >> Form Info >> click on "Edit the Error Message":

www.rsjoomla.com/support/documentation/v...form-properties.html
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.

Conditional validation 10 years 6 months ago #29005

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Thanks Silviup,

Maybe i wasn't specefic enough. I know how to make a field required.

The problem is i want to make a field requered only if a selection is done on a non-requered field.

In he example extra1 is not required so i can't set the other fields to required because is doesn't make any sense.

Hope this explains a bit more the challenge.

Hans
The administrator has disabled public write access.

Conditional validation 10 years 6 months ago #29013

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
You can use a PHP script that verifies the value chosen in, let's say, Field A and, based on that selection, invalidates Field B if no value was submitted within it.

To invalidate a field, you will need to use the following line of code (example):

$invalid[] = RSFormProHelper::getComponentId('maat1');

The script will need to be added in Components >> RSForm!Pro >> Manage Forms >> edit your form >> PHP Scripts >> Script called on form process.

You can read more on RSForm!Pro's PHP scripting areas here:

www.rsjoomla.com/support/documentation/v...602-php-scripts.html
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.

Conditional validation 10 years 6 months ago #29016

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Hi Silviup,

I'm afraid i don't quite understand. I've added the code to the $post-section of the form. However, whether i do or don't select a value for extra1 it gives in both cases an error that any value has to be selected.

Only when a value for extra1 is selected it should come with the error.

But thanks anyway for your time and posible solution!

Hans
The administrator has disabled public write access.

Conditional validation 10 years 6 months ago #29017

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
You will need to use that line of code within a condition:

if (condition)
{
$invalid[] = RSFormProHelper::getComponentId('maat1');
}
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.
The following user(s) said Thank You: parelweb

Conditional validation 10 years 6 months ago #29018

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Silviup,

Thanks for your support again. Unfortunately i'm not a programmer so i don't have a clue how to make the complete code.

I can imagine you don't want to write the code for me so i can implement it in the form. I'm fine with that :) .

In that case i'm going to use Google a bit more to find a possible solution.

Kind regards,
Hans
The administrator has disabled public write access.

Conditional validation 10 years 6 months ago #29026

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
Hi,

Please add the following code:

if ($_POST[0]<>"")
{
if($_POST[0]=="")
{
$invalid[]=RSFormProHelper::getComponentId('maat1');
}
elseif ($_POST[0]=="")
{
$invalid[]=RSFormProHelper::getComponentId('aantal1');
}
}

in Components >> RSForm!Pro >> Manage Forms >> edit your form >> Properties >> PHP Scripts >> Script called on form process.

Note that this code is suitable if you are using dropdowns for the 'extra1', 'maat1' and 'aantal1' fields.

Also, note that you should have an item with no value set as the default selection in the dropdown:

|Please select an item

Try this and let me know how it works out!
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.

Conditional validation 10 years 6 months ago #29029

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Hi Silviup,

The code doesn't seem to work. When i select an article and a size and submit there is no error. Besides hat it isn't possible to select the appropriate size again. The values in the pull-down don't show up.

If you want i can PM you with an export of the form.

Kind regards,
Hans
The administrator has disabled public write access.

Conditional validation 10 years 6 months ago #29032

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
Please try this code:
if ($_POST['form']['extra1'][0]<>"")
{
	if($_POST['form']['maat1'][0]=="")
	{
		$invalid[]=RSFormProHelper::getComponentId('maat1');
	}
	elseif ($_POST['form']['aantal1'][0]=="")
	{
		$invalid[]=RSFormProHelper::getComponentId('aantal1');
	}
}
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 10 years 6 months ago by silviup.
The administrator has disabled public write access.

Conditional validation 10 years 6 months ago #29035

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Hi Silviup,

I've implemented the code and it functions partially. twcpijnenburg.nl/index.php?option=com_rsform&formId=4 see matrix with extra items.

The strange thing still occurs that if i forget the number (aantal) and i submit the size (maat) dissapears and can't get reselected.

There is however for every extra item another script working. Depending on the selected item there will be different sizes available. See in backup file.

You can get a backup of the form here
Last Edit: 10 years 6 months ago by parelweb.
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!