禁止(disable)與開放(enable)輸入欄位(field)

禁止: document.form 名.欄位名.disable = false;
開放: document.form 名.欄位名.disable = true;
勾選可輸入內容

JavaScript 程式:

function fncEnable(){
  if(document.F.chk1.checked) document.F.txt1.disabled = false;
  else document.F.txt1.disabled = true;
}  



HTML 編寫:

<form name="F">
 <input type="checkbox" name="chk1" OnClick="fncEnable()">
 <input type="text" name="txt1" DISABLED>
</form>

小恐龍工作坊