Here is a mod of the script that should fit the bill (works here in limited trials, see notes at the bottom of this post):
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Agree Terms (w/terms scrolled to bottom? test) - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
//Modified Here by jscheuer1 in http://www.dynamicdrive.com/forums
//to also require scrolling to the bottom of the terms.
//Set id of Terms Textarea:
var termsId='terms'
//Set Agree Form Name:
var agreeform='agreeform'
//Set Agree Form Agree Checkbox Name:
var agreecheck='agreecheck'
/////////////No Need to Edit Below/////////
var ckSc, termsH, textA, checkobj, ok=0
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit"){
if(ok&&checkobj.checked)
tempobj.disabled=0
else {
if (checkobj.checked)
alert('At Least Read the Terms!')
tempobj.disabled=1
checkobj.checked=0
}
}
}
}
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
function checkScroll() {
if (textA.scrollTop>=termsH-10){
ok=1
clearInterval(ckSc)
}
}
function getH(){
document.forms[agreeform][agreecheck].checked=false
textA=document.all? document.all[termsId] : document.getElementById(termsId)
textA.scrollTop=0
var scT=scT1=scT2=textA.scrollTop
while (scT==scT1){
scT1+=1000
textA.scrollTop+=1000
scT=textA.scrollTop
}
textA.scrollTop=scT2
termsH=scT
ckSc=setInterval("checkScroll();",20)
}
if (document.all||document.getElementById)
onload=getH
</script>
</head>
<body>
<form name="agreeform" onSubmit="return defaultagree(this)">
<textarea id="terms" cols=50 rows=5 wrap=virtual>
DYNAMIC DRIVE SCRIPTS USAGE TERMS
1) Users may use any of the scripts found on Dynamic Drive on both personal and commercial web sites, free of charge. However, users may NOT redistribute, sell, or repost for download any of the scripts found on Dynamic Drive on any medium (CD-Rom, website, etc) without the expressed written permission of Dynamic Drive
2) Users agree not to remove the copyright notice inside each script.
3) Users agree not to use scripts found on Dynamic Drive for illegal purposes, or on pages containing illegal material.
4) Users agree not to hold Dynamic Drive liable for any damages resulted from proper or improper use of any of the scripts found on Dynamic Drive. Use at your own risk.
</textarea><br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br>
<input type="Submit" value="Submit!" disabled>
</form>
<script type="text/javascript">
document.forms[agreeform][agreecheck].checked=false
</script>
<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided by<br>
<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>
</body>
</html>
Notes: Requires that an id be assigned to the textarea containing the terms and that this id, as well as the name of the form and the name of the agree checkbox be configured in the script. Uses onload event to determine the scroll height of the terms text area. If you have other scripts on your page that use this event, there will be conflicts
Bookmarks