Setting up a minimum length validation

When using the Textbox or a Textarea field, you can use a small PHP script in order to define a minimum number of characters that can be typed.

More precisely, edit your form, go to Form Properties > PHP Scripts and add the following in the 'Script called on form process area':

// This is your field 'Name' property
$fieldName = 'your_field_name_here';
// This is the minimum length
$minLength = 3;
// No need to edit below
if (empty($_POST['form'][$fieldName]) || strlen($_POST['form'][$fieldName]) < $minLength)
{
  $invalid[] = RSFormProHelper::getComponentId($fieldName);
}
 

Make sure to replace 'your_field_name_here' with the actual name of your field, and 3 with your desired number.

 

Was this article helpful?

Yes No
Sorry about that