Solved

Disabling the Forms Submit button until a checkbox is selected

Posted on 2011-02-15
3
708 Views
Last Modified: 2012-05-11
Has anyone got a URL or a piece of JS code handy that can ensures a Form Submit button stays disabled until a checkbox is ticked?
0
Comment
Question by:kiwistag
3 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 125 total points
ID: 34895462
 function ex(obj)
{
if(obj.checked)
document.getElementById("submit").disabled=false;
}
 </script>
<input type='checkbox' id='check' onclick='ex(this)'>
<input type=submit id=submit  value='submit ' disabled >
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 34895529

Here's another example for you:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26821896.html</title>
<script src="http://code.jquery.com/jquery-1.4.3.min.js" language="javascript"></script>
<script language="JavaScript">

$(function() {

  $("#enable").click( validate );
  $("#process").attr( { disabled: true } );

});

function validate() {
  $("#process").attr( { disabled: !this.checked } );
}

</script>

</head>
<body>

<input id="enable" type="checkbox" />
<input id="process" type="button" value="Submit" /> 

</body>
</html>

Open in new window

0
 
LVL 6

Author Closing Comment

by:kiwistag
ID: 34895543
Was only missing <script> at the top but worked a dream - thanks :)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

821 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