Hi all and sorry for my bad english.

I have this form:

<code>
        $this->setAction('/' . Zend_Registry::get('language') .
self::$_action)
             ->setMethod($this->_method)
             ->setAttrib('id', 'activeCodeForm')

       $this->code = $this->createElement('text','code');

       $this->code->addValidator(new Zend_Validate_Alnum(false))
                ->addFilter('StringTrim')
                ->addValidator('StringLength',false,array(40,40))
                ->addValidator('NotEmpty')
                ->setLabel('Insert activation code:')
                ->setAttrib('size',40);

        $this->submit = new Zend_Form_Element_Submit('submit');
        $this->submit->setRequired(false)
              ->setIgnore(true)
              ->setLabel('Active');
</code>

And this is my Action() :

<code>
if (!$this->getRequest()->isPost()) {
           $this->view->form = new ActiveCodeForm;
           return;
       }

       $form = new ActiveCodeForm;

       if (!$form->isValid($_POST)) {
           echo "not valid";
           return;
       }

     echo "valid";
     return;
</code>

The validator works if I insert "a" or "aaaaaaaaaa"
(->addValidator('StringLength',false,array(40,40)))  or ">aaaa" ( new
Zend_Validate_Alnum(false))
But the problem is when I push "Active" button without insert something
into "code" text. For validator, the data is "valid".  Ok, I can set
"required true", but however the
addValidator('StringLength',false,array(40,40) could be not validated.

Where is my error?

Tnx.


--
Michel 'ZioBudda' Morelli                       [EMAIL PROTECTED]
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it MSN: [EMAIL PROTECTED]
                                                JABBER: [EMAIL PROTECTED]

Reply via email to