How to verify password field in zend form?

前端 未结 7 1411
旧巷少年郎
旧巷少年郎 2021-02-04 09:39

In my form, I\'m trying to verify that the user fills in the same value both times (to make sure they didn\'t make a mistake). I think that\'s what Zend_Validate_Identical

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 10:03

    For what its worth, support for comparing two identical form fields within a model was added to the 1.10.5 release. I wrote up a short tutorial on the matter, which you can access via the below link, but the bottom line is that the Zend_Validate_Identical validator has been refactored to accept a form field name as input. For instance, to compare the values of form fields pswd and confirm_pswd, you'll attach the validator to confirm_pswd like so:

    $confirmPswd->addValidator('Identical', false, array('token' => 'pswd'));
    

    Works like a charm.

    See Validating Identical Passwords with the Zend Framework for a more complete example.

提交回复
热议问题