»
EnglishFrenchVietnamese

Print - Agree Before Posting - JavaScriptBank.com

Full version: jsB@nk » Form » Validation » Agree Before Posting
URL: https://www.javascriptbank.com/agree-before-posting.html

Agree Before Posting © JavaScriptBank.comSometimes you may need to make sure your visitors agree to specific terms before submitting their comments. This JavaScript will disable the input fields until they agree to your terms. Easily adaptable.

Full version: jsB@nk » Form » Validation » Agree Before Posting
URL: https://www.javascriptbank.com/agree-before-posting.html



JavaScript
<script language="javascript"><!--// Created by: Savvy :: http://www.webdeveloper.com/forum/showthread.php?p=819275#post819275function enableob(o) { eval(o+".disabled = false"); }function disableob(o) { eval(o+".disabled = true"); }function toggleform(formstr,chkobstr,obstr) {var checked = eval(formstr+"."+chkobstr+".checked");var obs = obstr.split(",");  for (i = 0; i < obs.length; i++) {  obs[i] = formstr+"."+obs[i];  }  if (checked == false) {    for (i = 0; i < obs.length; i++) {    disableob(obs[i]);    }  }  else {    for (i = 0; i < obs.length; i++) {    enableob(obs[i]);    }    document.getElementById('pname').focus();  }}//--></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="myform"><p>To accept the license terms for posting, click the checkbox below:<br><input name="mycheck" onclick="toggleform('document.myform','mycheck','pname,pemail,ptext')" type="checkbox"> I Accept</p><table><tbody><tr><td><b>Name:</b></td><td><input id="pname" name="pname" disabled="true" type="textbox"></td></tr><tr><td><b>E-Mail:</b></td><td><input name="pemail" disabled="true" type="textbox"></td></tr><tr><td><b>Post:</b></td><td><textarea name="ptext" disabled="true"></textarea></td></tr></tbody></table></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->