Read full agreement and then say "I agree"

Lot of sites show some licence text, make you accept it and only then you can proceed with the download/next pages. In order to make sure that you read these, some UI applications have a feature that the "I Agree" button is activated only when you have scrolled through the entire licence agreement.

While this is easy to implement in WindowsUI, following a sample snippet how we implemented it in our web applications.

<div style="HEIGHT: 150px; OVERFLOW: auto" onscroll="javascript:displayScroll(this);">
I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/>
I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/>
I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/>
I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/>
I Agree I cannot agree to this agreement.<br/>I Agree I cannot agree to this agreement.<br/>
</div>
<input name="txtScroll">
<input value="Submit" type="button" name="btnIAgree">

<script language="javascript">
function displayScroll(val) {
document.getElementById("txtScroll").value = val.scrollTop + " " + val.scrollHeight + " " + val.clientHeight;
if(val.scrollTop + val.clientHeight == val.scrollHeight)
{
document.getElementById("btnIAgree").disabled=false;
}

}
</script>


Basically, we have used the scrollbar for div here and the scroll javascript event.
Inside the scroll event, we see if it has really reached the end and if yes, then we enable the button.

To Do Further
1. Validate if (val.scrollTop + val.clientHeight == val.scrollHeight) is really correct. I concluded this with just observation
2. If the agreement text is small, we need to enable the button on page load itself since there might not be any scrollbar.

Anyways, we can only ensure that the user has scrolled and can never ensure that user actually has read the agreement. We will need AI to be able to check if he really read the agreement :-).

Comments

Popular posts from this blog

Dirty workarouds: dirty page checking + AJAX

ASP Upload and localization