Solved

Disabling the Forms Submit button until a checkbox is selected

Posted on 2011-02-15
3
709 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

737 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