Hi, I need some help with this.
I am using webform and everything was going perfect until i put the email-field and confirm-email-field inside a fieldset.
This is the code that i am using for the validation:

<?php
if ($form_values['submitted_tree']['e_mail'] != $form_values['submitted_tree']['e_mail_2']) {
   
form_set_error('submitted][e_mail', t('E-mail addresses must match.'));
   }

$email_address = $form_values['submitted_tree']['e_mail'];
if (
strlen(trim($email_address)) > 0) {
   if (!
eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email_address))
  
form_set_error('submitted][email_address', t('Your email address is not valid.'));
   };
?>

The wierd thing is that if i take both email fields outside of the fieldset everything works fine.
Any idea about this? i searched the forum but didnt found anything yet... It is the first time that i have used the fieldset just trying to give to my form a better look.
Thanks in advance

Comments

machi27’s picture

I am very sorry, it is seems like as soon as i open a topic asking for help i can solve minors problems faster, honestly i was trying to solved this and searching for over 2 hours before asking, and nothing, but I realized that the mail field had change in some way.
Anyway it was just a syntax problem, i guess that whenever you put a field into a fieldset the name changes.
This is the final code and it is working perfect. Maybe someone needs it, just replace the ['contact_information'] for your fieldset container name.

<?php
if ($form_values['submitted_tree']['contact_information']['e_mail'] != $form_values['submitted_tree']['contact_information']['e_mail_2']) {
   
form_set_error('submitted][e_mail', t('E-mail addresses must match.'));
    }

$email_address = $form_values['submitted_tree']['contact_information']['e_mail'];
if (
strlen(trim($email_address)) > 0) {
    if (!
eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email_address))
   
form_set_error('submitted][email_address', t('Your email address is not valid.'));
};
?>

Thanks and sorry again