• 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: Make One of Three Fields Required.

Make One of Three Fields Required. 10 years 2 months ago #30447

I am not strong on scripting but was curious how to make this happen between three fields.

I ask the user about their phone numbers (i.e. home, work, and Cell). I need one phone number required, but would like to ask so we can receive as much information as the user will provide. I cannot mark all three fields as required fields because of a possible blank field. How do I script three fields that checks for at least one of the phone numbers in one of these fields without making all three required. I imagine it would need to check three fields for non-NULL values but I do not know how to do that.

Any help would be appreciated.

Start of form is here:
www.ccemmaus.org/index.php?option=com_rsform&formId=3
The administrator has disabled public write access.

Make One of Three Fields Required. 10 years 2 months ago #30455

  • silviup
  • silviup's Avatar
  • OFFLINE
  • Moderator
  • Posts: 309
  • Thank you received: 49
Unfortunately, RSForm!Pro does not include a default feature that would allow you to somehow combine 3 fields into a single validation rule. However, you can achieve this using a little bit of custom scripting.

Please add the following script in Components >> RSForm!Pro >> Manage Forms >> edit your form >> Properties >> PHP Scripts >> Script called on form process:
if(empty($_POST['form']['PilgrimHomePhone'])&&empty($_POST['form']['PilgrimWorkPhone'])&&empty($_POST['form']['PilgrimCellPhone']))
{
	  $invalid[] = RSFormProHelper::getComponentId('PilgrimHomePhone');	
	  $invalid[] = RSFormProHelper::getComponentId('PilgrimWorkPhone');	
	  $invalid[] = RSFormProHelper::getComponentId('PilgrimCellPhone');	
}

The code above will invalidate all 3 fields, if no information was submitted in any of them.

Make sure to NOT set any of the 3 fields as 'Required'.

If the user fills in at least one field, all 3 fields will pass validation.
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.
  • 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!