Solved

Submit button greyed out until checkbox checked

Posted on 2011-09-22
2
339 Views
Last Modified: 2012-05-12
How can I use Javascript to make a submit button greyed out until checkbox checked in the form?
0
Comment
Question by:a204801
  • 2
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
<input id="Submit" type="submit" disabled="disabled" value="Submit" />

<input type="checkbox" id="terms" onclick="if(this.checked) document.getElementById('Submit').removeAttribute('disabled');else document.getElementById('Submit').disabled = 'disabled'">

test page : http://jsfiddle.net/NspG7/
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
another one, just put the following in the head section : http://jsfiddle.net/NspG7/2/
<script language="javascript" type="text/javascript">
window.onload = function() {
    document.getElementById("terms").onchange = function() {
        if(this.checked) {
            document.getElementById('Submit').removeAttribute('disabled');
        }
        else {
            document.getElementById('Submit').disabled = 'disabled';
        }
    }
}
</script>

Open in new window


terms is the ID of your checkbox
Submit is the ID of your submit button
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now