Hi All,

I have a multi-page webform with 1 component shown on every page, so there's a pagebreak in between every component, with the exception of the 1st page. On the first page I added a hidden field that gets populated from the url parameter (i.e http://www.example.com/node/10?serialno=001, the ?serialno=001 part of the URL is added programmatically before the complete URL is sent to the user) and the default value of the hidden field is set as %get[serialno]. This works fine most of the time but some time I'm getting empty serialno (from my webserver log, somehow the query string is missing from the URL but that's another story). So just to be safe, I want to make sure that user can only submit if the hidden field is not an empty string. Apparently, the Mandatory checkbox is set by default for hidden field but it doesn't seems to affect hidden field at all. I've tried adding the following to the Additional Validation of the form but it always said the hidden field is empty.

<?php
   $serialno = $form_values['submitted_tree']['serialno'];
   if ($serialno == "") {
     form_set_error('submitted][serialno', t('Missing Serial#, please make sure you use the provided URL.'));
   }
?>

Can anyone help me out? Thanks in advance.

Comments

quicksketch’s picture

I don't provide support for custom validation functions in the Webform queue.

hendrakieran’s picture

Hi,

Thanks for responding. I'm not particularly asking for support for the custom validation script, the example is given to show what I've attempted. What I really need is a way to ensure, by whatever means, custom validation or otherwise, that the hidden field is not empty when user submit the form. Anyone?

navaneeth_r’s picture

Hi

I have tried the hidden field validation in Webform. Please follow the given code in form_alter.


if($form_id == 'PROVIDE YOUR WEBFORM ID') {
    $form['submitted']['PROVIDE FORM FIELD NAME']['#required'] = 1;
}

I hope this will support you.

R. Navaneethakrishnan
http://navaneethakrishnan-drupal.blogspot.com/

hendrakieran’s picture

Thanks a lot! that solved my problem.

hendrakieran’s picture

Status: Active » Closed (fixed)