• 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: Mutiple Validations on One Field at one Time

Mutiple Validations on One Field at one Time 10 years 2 months ago #30450

Hello;
Hope all is well. We want to apply Two validation rules on one field, for example we create a "Text Field" and want to apply to validation rules;

i) The Text Filed naming "ID No" should only have 13 digits of Numeric type and
ii) Secondly the ID No should not be duplicated

Please guide us how can we do this

Regards

Sohail
The administrator has disabled public write access.

Mutiple Validations on One Field at one Time 10 years 2 months ago #30451

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

This can be done, but part of the scenario will require some custom scripting. Follow these steps:

- edit the field, head to its 'Validations' tab and set 'Validation Rule' to 'Unique Field'
- head to the form's 'Properties' tab and, in 'PHP Scripts' >> 'Script called on form process' add the following code:
$string=strval($_POST['form']['number']);
$size=strlen($string);
$isnumber=is_numeric($_POST['form']['number']);
if(($size!=13)||($isnumber==false))
	 {$invalid[] = RSFormProHelper::getComponentId('number');}

Remember to replace 'number' with your field's actual name ('ID No' in your case).

The script above verifies if the submitted value is a number and if it's length is of no more or less than 13 characters. If these conditions are not met, the field will get invalidated.

The 'Unique Field' validation rule will verify if the submitted value already exists in the database. If the value is found, the field gets invalidated.

More information on these topics can be found here:

RSForm!Pro Textboxes: www.rsjoomla.com/support/documentation/v...cle/826-textbox.html

PHP Scripts: 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
Last Edit: 10 years 2 months ago by silviup.
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!