Sunday, 31 January 2016

Checkbox is checked and unchecked corresponding button disabled and enabled using javascript

<html>
<body>
<script LANGUAGE="JavaScript">

function ValidateForm()
{
   if ( document.form1.terms.checked == false )
     {
      
       
   document.getElementById("ss").disabled=true;
     }
   else
    {
      document.getElementById("ss").disabled=false;
     
    }
}

</script>
<br/><form name="form1">
<input type="checkbox" id="terms" value="Yes" onclick="ValidateForm()"/>
I accept Terms & Conditions:
<br/><br/>
<input type="button" name="SubmitButton" id="ss" disabled="disabled" value="Submit">

</form>
</body>
</html>


Output-1:









Output-2: