John Day wrote:


It is common that you need to make sure user entered same value in two
different fields - like with password fields.
I haven't found something like that in DFV - am I'm missing something?

It's not built-in, but perhaps it should be, because it so common to have a password or e-mail confirmation field.

Here's the DFV 4.0 constraint method I use for this:

=head2 eq_with

    password  => eq_with('password_confirm'),

Compares the current field to another field

=cut

sub eq_with {
    my ($other_field) = @_;
    return sub {
        my $dfv = shift;
        $dfv->name_this('eq_with');

        my $curr_val  = $dfv->get_current_constraint_value;

        my $data = $dfv->get_input_data;
        # Sometimes the data comes through both ways...
        my $other_val = (ref $data->{$other_field})
                ? $data->{$other_field}[0] : $data->{$other_field};

        return ($curr_val eq $other_val);
    }

}




---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to