Drupal webform validate either fields
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”.
Hi, How do I alter action in a form, created with webform ?
Thanks
Felipe,
You should be able to find the webform’s form id by looking at the source code when you’re viewing that form. Once you have that you can use either hook_form_alter() or hook_form_FORM_ID_alter() to make changes to the form.
http://api.drupal.org/api/function/hook_form_alter
-Mike
Thank you. wondering if there is any way to hide some fields from some role.