34 lines
688 B
JavaScript
34 lines
688 B
JavaScript
$(function () {
|
|
var $resend = $('#resend-code');
|
|
|
|
if ($resend.length === 0) {
|
|
return;
|
|
}
|
|
|
|
var seconds = 30;
|
|
|
|
function tick() {
|
|
if (seconds <= 0) {
|
|
$resend.prop('disabled', false).text('Отправить код ещё раз');
|
|
return;
|
|
}
|
|
|
|
$resend.prop('disabled', true).text('Отправить код ещё раз через ' + seconds + ' сек');
|
|
seconds--;
|
|
setTimeout(tick, 1000);
|
|
}
|
|
|
|
$resend.on('click', function (e) {
|
|
e.preventDefault();
|
|
|
|
if ($resend.prop('disabled')) {
|
|
return;
|
|
}
|
|
|
|
seconds = 30;
|
|
tick();
|
|
});
|
|
|
|
tick();
|
|
});
|