Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8244549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:53:26+00:00 2026-06-07T21:53:26+00:00

Struggling to understand why my validator chain is showing the incorrect message for the

  • 0

Struggling to understand why my validator chain is showing the incorrect message for the value I type in.

Currently my model’s code is making the incorrect message appear when I type in non-identical passwords instead of just the expected 3rd message (‘Please retype password between 8-25 alphanumeric characters and matching the first password‘ when expecting ‘Retyped password must match first.‘) when i type in mismatched passwords of 8 -25 characters long.

$password2 is the one giving issues

Also unsure if the indentical validator is working due to this problem.

Zend Framework version 1.11

Specific code chunk related to above

$password2 = new Zend_Form_Element_Password('password2');
$password2->setAttrib('size', 25);
$password2->setRequired(true);
$validatorChain2 = new Zend_Validate();
$validatorChain2->addValidator(new Zend_Validate_StringLength(array('min' => 8,'max' => 25)), true);
$validatorChain2->addValidator(new Zend_Validate_Alnum(false), true);
$validatorChain2->addValidator(new Zend_Validate_Identical('password1'), true);
$password2->addValidator($validatorChain2);
$password2->addErrorMessage('Please retype password between 8-25 alphanumeric characters and matching the first password');
$password2->addErrorMessage('Passwords can only be alphanumeric characters.');
        $password2->addErrorMessage('Retyped password must match first.');

Full model code listing

class Application_Model_RegisterNewAccount extends Zend_Form
{

    public function __construct($options = null)
    {
        // TODO: The errors are been grouped together at the top of the page now but the original error messages below each field need to be removed
        parent::__construct($options);

        $this->setName('newaccountregistration');
        $this->setMethod('post');
        $this->setAction($options['action']);   // Variable action passed via parameter array for argument 'action'

        $email = new Zend_Form_Element_Text('email');   // Create form text field
        $email->setAttrib('size', 75);  // Set for, element max size/length
        $email->setRequired(true);  // Make this field a required item

        $validator_email = new Zend_Validate_EmailAddress();
        $email->addValidator($validator_email);   // Set validator type and minimum and maximum size required
        $email->addErrorMessage('Please provide a valid email address');

        $firstname = new Zend_Form_Element_Text('firstname');
        $firstname->setAttrib('size', 35);
        $firstname->setRequired(true);

        $validator_firstname = new Zend_Validate_StringLength(array(1,35));
        $firstname->addValidator($validator_firstname);
        $firstname->addErrorMessage('Please provide your first name between 1-35 characters');

        $surname = new Zend_Form_Element_Text('surname');
        $surname->setAttrib('size', 35);
        $surname->setRequired(true);

        $validator_surname = new Zend_Validate_StringLength(array(1,35));
        $surname->addValidator($validator_surname);
        $surname->addErrorMessage('Please provide your first name between 1-35 characters');

        $password1 = new Zend_Form_Element_Password('password1');
        $password1->setAttrib('size', 25);
        $password1->setRequired(true);
        $validatorChain1 = new Zend_Validate();
        $validatorChain1->addValidator(new Zend_Validate_StringLength(array('min' => 8,'max' => 25)), true);
        $validatorChain1->addValidator(new Zend_Validate_Alnum(false), true);
        $password1->addValidator($validatorChain1);
        $password1->addErrorMessage('Please provide a password between 8-25 alphanumeric characters');
        $password1->addErrorMessage('Passwords can only be alphanumeric characters.');

        $password2 = new Zend_Form_Element_Password('password2');

        $password2->setAttrib('size', 25);
        $password2->setRequired(true);
        $validatorChain2 = new Zend_Validate();
        $validatorChain2->addValidator(new Zend_Validate_StringLength(array('min' => 8,'max' => 25)), true);
        $validatorChain2->addValidator(new Zend_Validate_Alnum(false), true);
        $validatorChain2->addValidator(new Zend_Validate_Identical('password1'), true);
        $password2->addValidator($validatorChain2);
        $password2->addErrorMessage('Please retype password between 8-25 alphanumeric characters and matching the first password');
        $password2->addErrorMessage('Passwords can only be alphanumeric characters.');
        $password2->addErrorMessage('Retyped password must match first.');

        $submit = new Zend_Form_Element_Submit('submit');   // Added submit button
        $submit->setLabel('Register');
        $submit->removeDecorator('DtDdWrapper'); // Remove the default DD div wrapper

        $this->setDecorators( array( array('ViewScript',
            array('viewScript' => '_register.phtml'))));    // The form html page

        $this->addElements(array($email, $firstname, $surname, $password1, $password2, $submit));   // Add all the form elements
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:53:27+00:00Added an answer on June 7, 2026 at 9:53 pm

    You should instantiate it like this…

    $validatorChain2->addValidator(new Zend_Validate_Identical(array('token' => 'password1', 'messages' => ....)), true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling to understand what precisely does it mean when a value has type
I am really struggling to understand why, when I change my code to use
Hi guys I was looking at this code but I'm struggling to understand what
I'm currently struggling to understand how I should organize/structure a class which I have
I'm struggling to understand the difference of the following 2 sets of code. The
I am struggling to understand a block of code which is extremely easy in
I am struggling to understand a possible memory leak in my code. I have
I have been struggling to understand some pieces of this code. It asks to
I'm struggling to understand why the following code is echoing out 'FOO2' when i'm
I am struggling to understand how this JavaScript code work. I am learning JS,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.