PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Drupal webform atleast one of the fields mandatory

February22

I am using webforms and I have three fields were either one of em should be filed.

Use the “additional validation” input box in the form “configuration”.

The code is following:

<?php
$book= $form_values['submitted'][11];
$author= $form_values['submitted'][12];
$isbn= $form_values['submitted'][13];

if (($book == NULL) AND ($author == NULL) AND ($isbn == NULL))
{
form_set_error(”, t(’Please enter either Book Title or Author or ISBN.’));
}
?>

The 11, 12 and 13 is the field id of your input fields. To find the field IDs mouse over the “edit” link next to your fields in the “Form Components”.

posted under Drupal
One Comment to

“Drupal webform atleast one of the fields mandatory”

  1. On April 13th, 2010 at 12:55 pm popop Says:

    k

Email will not be published

Website example

Your Comment:

 

2,885 spam comments
blocked by
Akismet