This is another enrichment tips to our usercake project: adding checkbox named “I Agree” and disable submit button before user check.
I got this script from dynamicdrive.com, and place it on modified usercake registration file.
add this script before closing </head>
<script> //"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 var checkobj 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") tempobj.disabled=!checkobj.checked } } } 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 } } } </script>
add this to form:
onSubmit="return defaultagree(this)"
so like this
<form name="newUser" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onSubmit="return defaultagree(this)">
replace this
<input type="submit" value="Register"/>
by this
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br> <input type="Submit" value="Register!" disabled>