Я использовал текстовую область только для чтения, чтобы отобразить свое лицензионное соглашение. Обратите внимание, что этот код не будет работать, если текст лицензионного соглашения недостаточно длинный, чтобы текстовая область отображала полосу прокрутки.
$(function () {
var serviceAgreementScrolled = false;
$('#service-agreement-textarea').scroll(
function () {
if (this.scrollTop + $(this).height() + 30 >= this.scrollHeight) {
serviceAgreementScrolled = true;
}
}
);
$('#accept-service-agreement-checkbox').change(
function () {
if ($(this).is(':checked') && !serviceAgreementScrolled) {
alert('Please scroll to read the rest of the service agreement.');
$(this).prop('checked', false);
}
}
);
});
<textarea id="service-agreement-textarea" readonly="readonly">Long long text here</textarea>
<label>
<input type="checkbox" id="accept-service-agreement-checkbox" />
I accept the terms of the service agreement
</label>