Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.2/normalize.min.css" rel="stylesheet" type="text/css" />
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <h2>Using preventDefault() to (sort of) disable form elements.</h2>
  <input type="radio">
  <input type="checkbox" checked>
  <textarea></textarea>
</body>
</html>
 
var radio = document.querySelector('input'),
    checkbox = document.querySelectorAll('input')[1],
    textarea = document.querySelector('textarea');
radio.addEventListener('click', function (e) {
  e.preventDefault();
}, false);
checkbox.addEventListener('click', function (e) {
  e.preventDefault();
}, false);
textarea.addEventListener('keypress', function (e) {
  e.preventDefault();
}, false);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
ImpressiveWebspro
0viewers