I want to check that 2 email fields are equals.

How i can pass two variables (from two different fields) in the validation function?

Is it possible??

I try this

if ($value == $form_state['values']['contatto_email']) {
  
    return TRUE;

  } else {

    return FALSE;

  }

Comments

pedrofaria’s picture

Category: support » feature

Hmmm what do you think to turn this request into a feature?

Maybe some thing like:


$form['myfield'] = array(
  '#type' => 'textfield',
  '#title' => 'My Field',
  '#required' => TRUE,
  '#rules' => array(
    'email', 
    'length[10, 50]', 
    array('rule' => 'alpha_numeric', 'error' => 'Please, use only alpha numeric characters at %field.'),
  ),
  '#filters' => array('trim', 'uppercase')
);

$form['myfield_confirmation'] = array(
  '#type' => 'textfield',
  '#title' => 'My Field',
  '#required' => TRUE,
  '#rules' => array(
    'match_field[myfield]'
  ),
  '#filters' => array('trim', 'uppercase')
);

We can create the rule match_field.

Ideas?

pedrofaria’s picture

Assigned: gabrielemontano » pedrofaria
Status: Active » Fixed

Will be available on next release.

barraponto’s picture

Check both http://api.drupal.org/api/drupal/includes%21form.inc/function/form_proce... and http://api.drupal.org/api/drupal/includes%21form.inc/function/password_c...

Since we're changing stuff during #process, we can replicate some this magic. I'm pretty sure there's a "confirm field" element in contrib, somewhere.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Add code example