I'm trying to add some additional validation to limit the amount of characters but I'm obviously not getting something right.

I started by copying the minimum validation example from the webform documentation page (http://drupal.org/node/237281) thinking it would be a simple switch since I'm doing the exact opposite. Here is the changed code below:

<?php
// The field with the key "plans_after_high_school" must have a maximum of 300 characters.
$max_length = 300;
if (strlen($form_values['plans_after_high_school']) > $max_length) {
  form_set_error('plans_after_high_school', 'Too many characters.');
}
?>

The field is in a group, and I tried prefixing the field with the group field key in square brackets.

Any help would be appreciated.

Sincerely,
Rene

Comments

quicksketch’s picture

The variable $form_values['plans_after_high_school'] will not exist, it should be $form_values['submitted_tree']['plans_after_high_school']

quicksketch’s picture

Status: Active » Closed (fixed)