Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Maybe someone will come in handy.
js:
We hang on the image container (you can immediately on the image).
And the request is sent to the route and the action responsible for generating the captcha.
/*refresh captcha*/
$('.captcha_container img').click(function(e) {
alert('hello');
$.ajax({
type: 'GET',
url: '/site/captcha',
data : {refresh: 1},
dataType: 'json',
success: function (data) {
$(".captcha_container img").attr('src', data.url);
}
});
});
view:
<?= $form->field($comment, 'verifyCode')->widget(Captcha::
'template' => '{image}{input}',
]) ?>
model:
public function rules() {
/*input email is email*/
return [
[['post_id', 'author', 'message', 'email'], 'required', 'on' => self::SCENARIO_SAVE],
['email', 'email'],
'captcha' => ['verifyCode', 'captcha','captchaAction'=>' site/captcha'],
];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question