Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 713
  • Last Modified:

Disabling the Forms Submit button until a checkbox is selected

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
kiwistag
Asked:
kiwistag
1 Solution
 
chaitu chaituCommented:
 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
 
ProculopsisCommented:

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
 
kiwistagAuthor Commented:
Was only missing <script> at the top but worked a dream - thanks :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now