CCaptcha validation is not working for the first time

Hi every one,

         I am newbie in Yii, but I have a registration form with CCaptcha. For the first time it has been raising an error "The verification code is incorrect.", though user enters right captcha code. But works from the next validation. Below I am giving my model rules and view code ..

Rule :

  1. array(‘verification_code’, ‘captcha’, ‘allowEmpty’=>!CCaptcha::checkRequirements(),‘on’=>‘registration’),

  2. array(‘verification_code’, ‘required’,‘on’=>‘registration’),

and the view code :

<?php if(CCaptcha::checkRequirements()): ?>

			&lt;div class=&quot;row&quot;&gt;

				&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'verification_code'); ?&gt;

				&lt;div class=&quot;captcha-img&quot;&gt;

				&lt;?php &#036;this-&gt;widget('CCaptcha', array(&quot;buttonLabel&quot;=&gt;false,'clickableImage'=&gt;true)); ?&gt;


				&lt;div class=&quot;captcha-input&quot;&gt;

				&lt;?php echo &#036;form-&gt;textField(&#036;model,'verification_code',array(&quot;alt&quot;=&gt;&quot;alfa&quot;,&quot;class&quot;=&gt;&quot;textbox&quot;)); ?&gt;


				&lt;div class=&quot;hint&quot;&gt;&lt;?php echo &#036;model-&gt;attributeHints('verification_code'); ?&gt;&lt;/div&gt;

				&lt;?php echo &#036;form-&gt;error(&#036;model,'verification_code'); ?&gt;


			&lt;?php endif; ?&gt;

                  Can anyone please tell me where do I leave a fault, so that I can remove this discrepancy?

See also: captcha is not working first time