+91-943-185-6038 me@shashidharkumar.com

Save this code as external JavaScript file named: agree.js

var agree=0;

// 0 = ‘no’, 1 = ‘yes’

function agree2() {
if (!document.getElementById) return false;
if (agree) {
document.getElementById(‘enterName’).style.visibility = ‘visible’;

function disagree() {
if (!document.getElementById) return false;
if (!agree) {
document.getElementById(‘enterName’).style.visibility = ‘hidden’;

function goSubmit() {
if (agree==0) {
alert(“DISGREE: You can insert the next step here”);
} else if (agree==1 && document.enableform.box.value==”) {
alert(“You must enter your name!”);
} else {
alert(“AGREE: You can insert the next step here”);

Save this code in the <style> section within the HEAD section of HTML document.

#enterName {
visibility: hidden;
padding-left: 50px;

Save this code into the HEAD section of HTML document
<script type=”text/javascript” src=”agree.js”></script>

Save this code into the BODY section of HTML document

<form name=”enableform”>
<input type=”radio” name=”enable” value=”agree” onclick=”agree2();”>I agree
<div id=”enterName”>Please enter your name to show agreement: <input type=text id=”box” name=”box”></div>
<input type=”radio” name=”enable” value=”disagree” onclick=”disagree();”>I disagree
<input type=”button” value=”Done!” name=”done” onclick=”goSubmit()”>

See also  JavaScript - Email Validation script