I have been trying to figure this out on my own, but I have had no luck. I know this is going to be simple for somebody..
Here is what I am trying to do:
There are instances where you want to force a user to view an entire piece of text. The particular instance that comes to mind is in the case of License Agreements. You want to be sure that the user has, at least, scrolled through the entire agreement before allowing them to proceed.
function textareaAtEnd(textareaObj)
{
return ((textareaObj.scrollTop + textareaObj.offsetHeight) > textareaObj.scrollHeight);
}
To use it, you would do:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Scroll Test</title>
<script language="JavaScript">
<!--
function textareaAtEnd(textareaObj)
{
return ((textareaObj.scrollTop + textareaObj.offsetHeight) > textareaObj.scrollHeight);
}
function formValidation(formObj)
{
if (textareaAtEnd(formObj.licenseAgreement))
{
return true;
}
else
{
alert ("Please scroll to the end of the license agreement.")
return false;
}
}
// -->
</script>
I have tried everything I know, which isn't much. I am hoping once this is shown to me I will understand were I was going wrong.
Thanks,
Doug