• 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: Validate field as number between min and max

Validate field as number between min and max 10 years 11 months ago #27784

  • alank
  • alank's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi,

I'm building a product purchase registration form, which includes a serial number field (purely numeric, but 10 digits long). I thought I'd validate as far as I can by requiring it to be a number between a min value and a max value, but I'm not sure how to go about it. Any tips would be much appreciated!
The administrator has disabled public write access.

Validate field as number between min and max 10 years 11 months ago #27789

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can set the validation rule to numeric and insert in Scripts called on form process (Form properties > PHP Scripts)
 
if(strlen($_POST['form']['field_name']) != 10){
$invalid[] = RSFormProHelper::getComponentId("field_name");
}
 

This script will verify if the value from "field_name" has 10 characters and if it finds less or more characters, it will invalidate it.
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: dominic.weiss, alank
  • 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!