Link to home
Start Free TrialLog in
Avatar of kiwistag
kiwistagFlag for New Zealand

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Proculopsis
Proculopsis


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

Avatar of kiwistag

ASKER

Was only missing <script> at the top but worked a dream - thanks :)