I changed the code.  Its working (Showing validation error message for
password and confirm_password.)

code:

controller:

function index()
{
        if(!empty($this->data['Client'])) {
                   if($this->Client->isConfirm('password', $this->data['Client']
['password'],$this->data['Client']['confirm_password']))
                   {
                       if ($this->Client->save($this->data))
                {
                        $this->flash('Your post has been saved.','/clients/
register2');
                                }
                   }
                }
 }

Model

function isConfirm($field,$v1,$v2) {
        if($v1 != $v2) {
            $this->invalidate('confirm_'.$field);
            return false;
        } else  return true;
    }



var $validate = array(
        'email'   =>            VALID_NOT_EMPTY,
        'fname'   =>                    VALID_NOT_EMPTY,
        'lname'   =>            VALID_NOT_EMPTY,
        'username'   =>                 VALID_NOT_EMPTY,
        'password'   =>                 VALID_NOT_EMPTY,
        'confirm_password'   => VALID_NOT_EMPTY,
                'contact1'   =>                 VALID_NOT_EMPTY

        );


Views

                Password
                <?php echo $html->tagErrorMsg('Client/password', 'Password is
required.') ?>
                <?php echo $html->input('Client/password', array('size' => 
'10'))?>
<p>

                Confirm Password
                <?php echo $html->tagErrorMsg('Client/confirm_password', 
'Password
Mismatch.') ?>
                <?php echo $html->input('Client/confirm_password', array('size' 
=>
'10'))?> <p>


But, validation for other fields i.e if it is empty, validation
message was displaying.







On May 31, 2:24 pm, <[EMAIL PROTECTED]> wrote:
> What do you mean with doesn't work.
> For All:  "Be more exhausting when you place a question"
>
> It could be this.
>
> if(($this->data['Client']['password'])!=($this->data['Client']['confirm_pas-s
> word'])) {
>         $this->Client->invalidate('confirm_password');
>         return;
>
>
>
> }
> > -----Messaggio originale-----
> > Da: [email protected]
> > [mailto:[EMAIL PROTECTED] Per conto di cake_learner
> > Inviato: giovedì 31 maggio 2007 10.06
> > A: Cake PHP
> > Oggetto: validation
>
> > I want confirm password to be validated. (Both password and
> > confirm password should be same)
>
> > views:
>
> >            Password
> >            <?php echo
> > $html->tagErrorMsg('Client/password', 'Password is
> > required.') ?>
> >            <?php echo $html->input('Client/password',
> > array('size' => '10'))?> <p>
>
> >            Confirm Password
> >            <?php echo
> > $html->tagErrorMsg('Client/confirm_password', 'Confirm
> > Password is required.') ?>
> >            <?php echo
> > $html->input('Client/confirm_password', array('size' => '10'))?> <p>
>
> > controller:
>
> >       function index() {
>
> >       if (!empty($this->data))
> >         {
>
> > if(($this->data['Client']['password'])!=($this->data['Client']
> > ['confirm_password']))
> >                    $this->Client->invalidate('confirm_password');
>
> >             if ($this->Client->save($this->data))
> >             {
> >                 $this->flash('Your post has been
> > saved.','/clients/ register2');
> >                    }
> >                    else
> >                    {
> >                         $this->render();
> >                    }
> >         }
>
> >       }
>
> > The above code is not working.- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to