Skip to content

Instantly share code, notes, and snippets.

@reywood
Created January 30, 2014 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reywood/8721917 to your computer and use it in GitHub Desktop.
Save reywood/8721917 to your computer and use it in GitHub Desktop.
Modify checkbox state based on input value
<html>
<head>
<script>
function handleKeyUp(input) {
document.getElementById('cb').checked = input.value.length > 0;
}
</script>
</head>
<body>
<input type="checkbox" id="cb">
<input type="text" onkeyup="javascript: handleKeyUp(this);">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment