Captcha widget "Get a new code" not working

I really hope someone will be able to help me with this

I’m using the captcha widget on two pages on the contact us page and on the registration page, now when I click on the link GET A NEW CODE on the registration page no new link is generated, although it works on the contact us page. I get a javascript error jQuery(“refreshCaptcha”).live is not a function .

My code looks as follows

CONTROLLER


<?php


class UsersController extends Controller

{

	/**

	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning

	 * using two-column layout. See 'protected/views/layouts/column2.php'.

	 */

	public $layout='';


	/**

	 * @var CActiveRecord the currently loaded data model instance.

	 */

	private $_model;


	/**

	 * @return array action filters

	 */

	public function filters()

	{

		return array(

			'accessControl', // perform access control for CRUD operations

		);

	}

	

	public function actions()

        {

                return array(

                        // captcha action renders the CAPTCHA image displayed on the contact page

                        'captcha'=>array(

			'class'=>'CCaptchaAction',

                        'backColor'=>0xFFFFFF,

                ),

                        );

        }


	/**

	 * Specifies the access control rules.

	 * This method is used by the 'accessControl' filter.

	 * @return array access control rules

	 */

	public function accessRules()

	{

		return array(

			array('allow',  // allow all users to perform 'index' and 'view' actions

				'actions'=>array('create','captcha'),

				'users'=>array('*'),

			),

			array('allow', // allow authenticated user to perform 'create' and 'update' actions

				'actions'=>array('update','view','captcha'),

				'users'=>array('@'),

			),

			//array('allow', // allow admin user to perform 'admin' and 'delete' actions

			//	'actions'=>array('admin','delete'),

			//	'users'=>array('admin'),

			//),

			array('deny',  // deny all users

				'users'=>array('*'),

			),

		);

	}


	/**

	 * Displays a particular model.

	 */

	public function actionView()

	{

		$this->render('view',array(

			'model'=>$this->loadModel(),

		));

	}


	/**

	 * Creates a new model.

	 * If creation is successful, the browser will be redirected to the 'view' page.

	 */

	public function actionCreate()

	{

		$model=new Users;

		

		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


		if(isset($_POST['Users']))

		{

			$model->attributes=$_POST['Users'];

			if($model->save())

				$this->redirect(array('view','id'=>$model->usr_id));

		}


		$this->render('create',array(

			'model'=>$model,

		));

	}


	/**

	 * Updates a particular model.

	 * If update is successful, the browser will be redirected to the 'view' page.

	 */

	public function actionUpdate()

	{

		$model=$this->loadModel();


		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


		if(!isset($_POST['Users'])){

			$model->retype_Password = $model->usr_password;

		}else{

			$model->retype_Password = $_POST['Users']['retype_Password'];

		}


		if(isset($_POST['Users']))

		{

			$model->attributes=$_POST['Users'];

			if($model->save())

				$this->redirect(array('view','id'=>$model->usr_id));

		}


		$this->render('update',array(

			'model'=>$model,

		));

	}


	/**

	 * Deletes a particular model.

	 * If deletion is successful, the browser will be redirected to the 'index' page.

	 */

	public function actionDelete()

	{

		if(Yii::app()->request->isPostRequest)

		{

			// we only allow deletion via POST request

			$this->loadModel()->delete();


			// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser

			if(!isset($_GET['ajax']))

				$this->redirect(array('index'));

		}

		else

			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');

	}


	/**

	 * Lists all models.

	 */

	public function actionIndex()

	{

		$dataProvider=new CActiveDataProvider('Users');

		$this->render('index',array(

			'dataProvider'=>$dataProvider,

		));

	}


	/**

	 * Manages all models.

	 */

	public function actionAdmin()

	{

		$model=new Users('search');

		$model->unsetAttributes();  // clear any default values

		if(isset($_GET['Users']))

			$model->attributes=$_GET['Users'];


		$this->render('admin',array(

			'model'=>$model,

		));

	}


	/**

	 * Returns the data model based on the primary key given in the GET variable.

	 * If the data model is not found, an HTTP exception will be raised.

	 */

	public function loadModel()

	{

		if($this->_model===null)

		{

			if(isset(Yii::app()->user->id))

				$this->_model=Users::model()->findbyPk(Yii::app()->user->id);

			if($this->_model===null)

				throw new CHttpException(404,'The requested page does not exist.');

		}

		return $this->_model;

	}


	/**

	 * Performs the AJAX validation.

	 * @param CModel the model to be validated

	 */

	protected function performAjaxValidation($model)

	{

		if(isset($_POST['ajax']) && $_POST['ajax']==='users-form')

		{

			echo CActiveForm::validate($model);

			Yii::app()->end();

		}

	}

}



MODEL


<?php


class Users extends CActiveRecord

{

	

	public $retype_Password;

	public $verifyCode;

	/**

	 * Returns the static model of the specified AR class.

	 * @return Users the static model class

	 */

	public static function model($className=__CLASS__)

	{

		return parent::model($className);

	}


	/**

	 * @return string the associated database table name

	 */

	public function tableName()

	{

		return 'users';

	}


	/**

	 * @return array validation rules for model attributes.

	 */

	public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('usr_username,usr_firstname,usr_lastname,usr_email,usr_birth_date,usr_password,usr_cell', 'required'),

			array('usr_tel,usr_cell', 'numerical', 'integerOnly'=>true),

			array('usr_username, usr_firstname, usr_lastname, usr_password', 'length', 'max'=>32),

			array('usr_password', 'compare', 'compareAttribute'=>'retype_Password'),

			array('usr_email', 'length', 'max'=>128),

			array('usr_email', 'email'),

			array('usr_tel, usr_cell', 'length', 'max'=>15),

			array('usr_birth_date,retype_Password', 'safe'),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('usr_id,usr_username,usr_firstname,usr_lastname,usr_email,usr_tell,usr_birth_date,usr_password,retype_Password,usr_last_visit,usr_current_visit,usr_last_post,usr_chats,usr_comments,usr_forums,usr_ip,usr_number_visits,createdate,moddate', 'safe', 'on'=>'search'),

			array('moddate','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'update'),

			array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd')),

			array('createdate,moddate','default','value'=>new CDbExpression('NOW()'),'setOnEmpty'=>false,'on'=>'insert')

		);

	}


	/**

	 * @return array relational rules.

	 */

	public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

		);

	}


	/**

	 * @return array customized attribute labels (name=>label)

	 */

	public function attributeLabels()

	{

		return array(

			'usr_id' => 'Usr',

			'usr_username' => 'Username',

			'usr_firstname' => 'First Name',

			'usr_lastname' => 'Last Name',

			'usr_email' => 'Email Address',

			'usr_tel' => 'Telephone Number',

			'usr_cell' => 'Cellphone Number',

			'usr_birth_date' => 'Birth Date',

			'usr_password' => 'Password',

			'usr_last_visit' => 'Last Visit',

			'usr_current_visit' => 'Usr Current Visit',

			'usr_last_post' => 'Usr Last Post',

			'usr_chats' => 'Usr Chats',

			'usr_comments' => 'Usr Comments',

			'usr_forums' => 'Usr Forums',

			'usr_ip' => 'IP Address',

			'usr_number_visits' => 'Times Visited',

			'createdate'=>'Creation Date',

			'moddate'=>'Modification Date',

			'verifyCode'=>'Verification Code',

		);

	}


	/**

	 * Retrieves a list of models based on the current search/filter conditions.

	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.

	 */

	public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;


		$criteria->compare('usr_id',$this->usr_id);


		$criteria->compare('usr_firstname',$this->usr_firstname,true);


		$criteria->compare('usr_lastname',$this->usr_lastname,true);


		$criteria->compare('usr_email',$this->usr_email,true);


		$criteria->compare('usr_identity_no',$this->usr_identity_no,true);


		$criteria->compare('usr_tel',$this->usr_tel,true);


		$criteria->compare('usr_cell',$this->usr_cell,true);


		$criteria->compare('usr_fax',$this->usr_fax,true);


		$criteria->compare('usr_birth_date',$this->usr_birth_date,true);


		$criteria->compare('usr_gender',$this->usr_gender,true);


		$criteria->compare('usr_receive_sms',$this->usr_receive_sms);


		$criteria->compare('usr_receive_email',$this->usr_receive_email);


		$criteria->compare('usr_is_member',$this->usr_is_member);


		$criteria->compare('usr_member_no',$this->usr_member_no,true);


		$criteria->compare('usr_password',$this->usr_password,true);


		$criteria->compare('usr_profile_name',$this->usr_profile_name,true);


		$criteria->compare('usr_profile_title',$this->usr_profile_title,true);


		$criteria->compare('usr_profile_signature',$this->usr_profile_signature,true);


		$criteria->compare('usr_profile_avatar',$this->usr_profile_avatar);


		$criteria->compare('usr_profile_image',$this->usr_profile_image);


		$criteria->compare('usr_profile_hide_email',$this->usr_profile_hide_email);


		$criteria->compare('usr_join',$this->usr_join);


		$criteria->compare('usr_last_visit',$this->usr_last_visit);


		$criteria->compare('usr_current_visit',$this->usr_current_visit);


		$criteria->compare('usr_last_post',$this->usr_last_post);


		$criteria->compare('usr_chats',$this->usr_chats);


		$criteria->compare('usr_comments',$this->usr_comments);


		$criteria->compare('usr_forums',$this->usr_forums);


		$criteria->compare('usr_ip',$this->usr_ip,true);


		$criteria->compare('usr_ban',$this->usr_ban);


		$criteria->compare('usr_visits',$this->usr_visits);


		$criteria->compare('active',$this->active);


		return new CActiveDataProvider('Users', array(

			'criteria'=>$criteria,

		));

	}

	

	/**

	 * Hashing Password before saving it to the database

	 */ 

	public function beforeValidate(){

		//Now we are checking if the username already exists or not

		$connection=$this->dbConnection->createCommand("SELECT * FROM ".$this->tableName()." WHERE usr_username = '".$this->usr_username."'");

		$row=$connection->queryRow();

		

		if($this->isNewRecord){

			

			if(!empty($row['usr_username'])){

				$this->addError('usr_username','Username: '.$this->usr_username.' already exists');

				return false;

			}else{

				return true;

			}

			

		}else{

			//Now we are checking if the username already exists or not

			$connection=$this->dbConnection->createCommand("SELECT * FROM ".$this->tableName()." WHERE usr_id = '".$this->usr_id."'");

			$row1=$connection->queryRow();

			

			if(!empty($row['usr_username'])){

				

				if($row1['usr_username'] == $this->usr_username){

					return true;	

				}else{

					$this->addError('usr_username','Username: '.$this->usr_username.' already exists');

					return false;

				}

			}

		}

		return true;

	}

	

	

	protected function beforeSave(){

		$connection=$this->dbConnection->createCommand("SELECT * FROM ".$this->tableName()." WHERE usr_id = '".$this->usr_id."'");

		$row=$connection->queryRow();

		if($this->usr_password != $row['usr_password']){

			$this->usr_password = $this->getMD5Password($this->usr_password);

		}

		return true;

	}

	

	/**

	 * This method returns the md5 value of the password entered

	 *

	 * @param string $password

	 * @return string returns the md5 value of the password

	 */

	private function getMD5Password($password){

		$pass = md5($password);

		return $pass;

	}

	

	

        /**

	 * Checks if the given password is correct.

	 * @param string the password to be validated

	 * @return boolean whether the password is valid

	 */

	public function validatePassword($password)

	{

		return $this->hashPassword($password)===$this->usr_password;

	}


	/**

	 * Generates the password hash.

	 * @param string password

	 * @return string hash

	 */

	public function hashPassword($password)

	{

		return md5($password);

	}

	

	/**

	 * This method inserts the usr_last_visit and updates usr_number_visits values in the database. Also captures the users IP address

	 * so that we can keep track of all user activity

	 *

	 * @return boolean

	 */

	public function updateLoginActivity(){

		$id = Yii::app()->user->id;

		

		$connection=$this->dbConnection->createCommand("SELECT usr_number_visits FROM ".$this->tableName()." WHERE usr_id = :usr_id");

		$connection->bindParam(':usr_id',$id,PDO::PARAM_INT);

		$row=$connection->queryRow();

		$count = null;

		$count= $row['usr_number_visits'] + 1;

		

		$lastLogin = date('Y-m-d H:i:s');

		$usr_ip = $_SERVER['REMOTE_ADDR'];

		

		$command = $this->dbConnection->createCommand("UPDATE ".$this->tableName()." SET usr_ip = :usr_ip, usr_number_visits = :usr_number_visits, usr_last_visit = :usr_last_visit WHERE usr_id = :usr_id");

		$command->bindParam(":usr_ip",$usr_ip,PDO::PARAM_STR);

		$command->bindParam(":usr_number_visits",$count,PDO::PARAM_INT);

		$command->bindParam(":usr_last_visit",$lastLogin);

		$command->bindParam(":usr_id",$id,PDO::PARAM_INT);

		$command->execute();

		

		return true;

	}

	

}

VIEW


<div id="text">

<div class="form">


<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'users-form',

	'enableAjaxValidation'=>false,

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<?php echo $form->errorSummary($model); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'usr_username'); ?>

		<?php echo $form->textField($model,'usr_username',array('size'=>20,'maxlength'=>32)); ?>

		<?php echo $form->error($model,'usr_username'); ?>

	</div>

	

	<div class="row">

		<?php echo $form->labelEx($model,'usr_password'); ?>

		<?php echo $form->passwordField($model,'usr_password',array('size'=>20,'maxlength'=>32)); ?>

		<?php echo $form->error($model,'usr_password'); ?>

	</div>

	

	<div class="row">

		<?php echo $form->labelEx($model,'retype_Password'); ?>

		<?php echo $form->passwordField($model,'retype_Password',array('size'=>20,'maxlength'=>32)); ?>

		<?php echo $form->error($model,'retype_Password'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'usr_firstname'); ?>

		<?php echo $form->textField($model,'usr_firstname',array('size'=>20,'maxlength'=>32)); ?>

		<?php echo $form->error($model,'usr_firstname'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'usr_lastname'); ?>

		<?php echo $form->textField($model,'usr_lastname',array('size'=>20,'maxlength'=>32)); ?>

		<?php echo $form->error($model,'usr_lastname'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'usr_email'); ?>

		<?php echo $form->textField($model,'usr_email',array('size'=>20,'maxlength'=>128)); ?>

		<?php echo $form->error($model,'usr_email'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'usr_cell'); ?>

		<?php echo $form->textField($model,'usr_cell',array('size'=>20,'maxlength'=>15)); ?>

		<?php echo $form->error($model,'usr_cell'); ?>

	</div>

	<div class="row">

		<?php echo $form->labelEx($model,'usr_birth_date'); ?>

		<?php

		$this->widget('application.extensions.jui.EDatePicker',

		array(

                    'name'=>'Users[usr_birth_date]',

		    'value'=>$model->usr_birth_date,

                    'language'=>'en',

                    'mode'=>'imagebutton',

                    'theme'=>'smoothness',

		    'fontSize'=>'0.78em',

                    'htmlOptions'=>array('size'=>20),

                   )

		);

		?>

		<?php echo $form->error($model,'usr_birth_date'); ?>

	</div>

	

	<?php if(extension_loaded('gd')): ?>

	<div class="row">

		<?php echo $form->labelEx($model,'verifyCode'); ?>

		<div>

		<?php $this->widget('CCaptcha',array(

            'showRefreshButton'=>true,'buttonOptions'=>array('id'=>'refreshCaptcha')

)); ?>

		<?php echo $form->textField($model,'verifyCode'); ?>

		</div>

		<div class="hint">Please enter the letters as they are shown in the image above.

		<br/>Letters are not case-sensitive.</div>

	</div>

	<?php endif; ?>

	


	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>

	</div>


<?php $this->endWidget(); ?>


</div><!-- form -->

</div>

Am I doing something wrong here?

I’ve found the answer to the problem, the problem was that I included the JQuery library twice and that somehow caused the issue.

[url=&quot;http://www.techportal.co.za&quot;]

[/url]

Follow this tutorial for best help -

http://www.dukaweb.net/2013/12/why-does-yii-captcha-not-display-get-new-code-yii-tutorial.html