「テキストボックスを無効化」
<input type="text">
でテキストボックスを表示しますが、キーボードからの入力を不可能にする方法は?
回答
以下、3種類の方法で入力不可にします。
ボタンをおしてJavaScriptからの入力は可能です。
ソース
<html><head>
<meta http-equiv='Content-Type' content='text/html;charset=Shift_JIS'>
</head>
<script language='JavaScript'>
function test(a){
document.all.fm.tx1.value=a;
document.all.fm.tx2.value=a;
document.all.fm.tx3.value=a;
}
</script>
<body>
<form name='fm'>
<input type='button' value='入力' name='bt' onClick="test('JavaScriptからは入力可能');">
<input type='text' size='30' name='tx1' OnFocus='blur();'>
<input type='text' size='30' name='tx2' OnFocus='blur();' disabled>
<input type='text' size='30' name='tx3' readonly>
</form>
</body>
</html>