• 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: Change Validation Rule by dropDown

Change Validation Rule by dropDown 10 years 8 months ago #28428

hi everyone,
i want to make a form.
a Drop-down that have many item, and a text field that validation of it is depend on Drop-Down item.
for Example we have one Drop-Down that called DRP and textField that called TXTF. my drop down item is look like this:

Orange
Blue
White
Black

If Orange selected, you can only enter 3 code on TXTF! like:
826653
972654
812467

If Blue selected TXTF only accept this code:
982361
672541
872123

how i can do it, i haven`t any problem in make Custom validation rules. but think i need something like make 4 Validation rule (for Orange, Blue, White and Black) and Condition field that change validation Rule instead of show or hide option.
does anyone have any solution for this?
sorry for bad english
The administrator has disabled public write access.

Change Validation Rule by dropDown 10 years 8 months ago #28429

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can create a script for the Scripts called on form process area to check the value of the dropdown and depending on it's value, to check if the value inserted in the text area belongs to the given array.

An example on this can be found below:
$orange = array(826653, 972654, 812467);
$blue = array(982361, 672541, 872123);
 
if($_POST['form']['dropdown_field_name'][0] == "Orange"){
	if(!in_array($_POST['form']['textbox_field_name'], $orange)){
		$invalid[] = RSFormProHelper::getComponentId("textbox_field_name");
	}
}
else if($_POST['form']['dropdown_field_name'][0] == "Blue"){
	if(!in_array($_POST['form']['textbox_field_name'], $blue)){
		$invalid[] = RSFormProHelper::getComponentId("textbox_field_name");
	}
}

More information on PHP scripts can be found in the following article:
www.rsjoomla.com/support/documentation/view-article/602-php-scripts.html
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: JavadJaan

Change Validation Rule by dropDown 10 years 8 months ago #28430

hi, thanks for your reply.
but plz help me step by step.
first i make my DropDown
2) make text field
3) add this code to Scripts.
is it true?
The administrator has disabled public write access.

Change Validation Rule by dropDown 10 years 8 months ago #28431

And another question, should i use any Validation Rule?
The administrator has disabled public write access.

Change Validation Rule by dropDown 10 years 8 months ago #28433

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
As you previously stated, you already have a dropdown field and a text field, the only thing you need to do is to insert the name of the fields in the code:

e.g.
if($_POST['form']['dropdown_field_name'][0] == "Orange"){
	if(!in_array($_POST['form']['textbox_field_name'], $orange)){
		$invalid[] = RSFormProHelper::getComponentId("textbox_field_name");
	}
}
 
// change these fields to:
 
if($_POST['form']['DRP'][0] == "Orange"){
	if(!in_array($_POST['form']['TXTF'], $orange)){
		$invalid[] = RSFormProHelper::getComponentId("TXTF");
	}
}

You won't need other validation rules, please don't forget to add it in the Scripts called on form process area.
My help is not official customer support. To receive your support, submit a ticket by clicking here
Last Edit: 10 years 8 months ago by cosmin.cristea.
The administrator has disabled public write access.
The following user(s) said Thank You: JavadJaan

Change Validation Rule by dropDown 10 years 8 months ago #28434

Ok, but can I use utf8 charecter in my dropdown?
looklike arabic or persian?
if($_POST['form']['dropdown_field_name'][0] == "نارنجی"){
	if(!in_array($_POST['form']['textbox_field_name'], $orange)){
		$invalid[] = RSFormProHelper::getComponentId("textbox_field_name");
	}
}
at if, it must be equal to a UTF8 variable!
is it ok?
Last Edit: 10 years 8 months ago by JavadJaan.
The administrator has disabled public write access.

Change Validation Rule by dropDown 10 years 8 months ago #28446

Hi
the if isn't work when i use dropDown like this "سلام | 18900"!
can you help me?
The administrator has disabled public write access.

Change Validation Rule by dropDown 10 years 8 months ago #28451

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
A dropdown item is created as value | label. The if condition will take in consideration only the value, you will have to create your if statement as :
if($_POST['form']['dropdown_field_name'][0] == 18900){
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: JavadJaan
  • 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!