Hey all, I've started a script but can't quite get it right.
I have two inputs for email address and confirm email address. If both those fields have the same value, then a <div> containing a checkbox should display. If they don't match, it should stay hidden.
That catch is that the script needs to trigger on both page load (if the fields are pre-popped), and as they fill out the confirm field.
This is what I have so have (has multiple issues):
<script>
function showAgree() {
if (document.getElementById("email").value=document.getElementById("confirm").value) {
document.getElementById("agree").style.display = '';
}
else {
document.getElementById("agree").style.display = 'none';
}
}
</script>
</head>
<body>
Email Address
<label>
<input type="text" name="email" id="email" />
</label>
<p>Confirm Address
<label>
<input type="text" name="confirm" id="confirm" onKeyUp="showAgree();"/>
</label>
</p>
<div id="agree">
<label>
<input type="checkbox" name="checkbox" id="checkbox" />
</label>
I agree to receive emails
</div>
</body>
Any ideas?
Thanks
RK
I have two inputs for email address and confirm email address. If both those fields have the same value, then a <div> containing a checkbox should display. If they don't match, it should stay hidden.
That catch is that the script needs to trigger on both page load (if the fields are pre-popped), and as they fill out the confirm field.
This is what I have so have (has multiple issues):
<script>
function showAgree() {
if (document.getElementById("email").value=document.getElementById("confirm").value) {
document.getElementById("agree").style.display = '';
}
else {
document.getElementById("agree").style.display = 'none';
}
}
</script>
</head>
<body>
Email Address
<label>
<input type="text" name="email" id="email" />
</label>
<p>Confirm Address
<label>
<input type="text" name="confirm" id="confirm" onKeyUp="showAgree();"/>
</label>
</p>
<div id="agree">
<label>
<input type="checkbox" name="checkbox" id="checkbox" />
</label>
I agree to receive emails
</div>
</body>
Any ideas?
Thanks
RK