禁止輸入法
形式:
<INPUT TYPE=text STYLE="ime-mode:disabled" >
參數說明形式:
active 代表輸入法為中文
inactive 代表輸入法為英文
auto 代表打開輸入法 (默認)
disable 代表關閉輸入法
具體例子如下:
<INPUT onfocus=" this.style.imeMode='active' " /> <INPUT onfocus=" this.style.imeMode='inactive' " /> <INPUT onfocus=" this.style.imeMode='auto' " /> <INPUT onfocus=" this.style.imeMode='disabled' " />
禁止input 粘貼
具體例子如下:
<input id=VC class="xinput" maxlength=4 size="5" onkeydown="fnKeyDown(event);" onfocus="this.select()" onclick="this.select()" onpaste="return false" ondrop="return false" ondragenter="return false;" ondragstart="return false" onkeypress="return keyDigt(event)" value=""/>
參數說明:
ondragstart="return false" 禁止鼠標在網頁上拖動
ondragenter 當用戶拖曳對象到一個合法拖曳目標時在目標元素上觸發
onpaste="return false" 禁止粘貼
其他方法
方法一:
在ie可以完全屏蔽input 輸入,但firefox上面去掉了光標,還是可以輸入字符
<input type="file" id="file1" contenteditable="false" />
方法二:
用checkbox控制.....
<script language="javascript"> function ischeck(){ var ischeck=document.form1.iswrite.checked; var isshow=document.getElementById("show"); if (ischeck==true){ isshow.disabled=""; }else{ isshow.disabled="disabled"; } } </script>
HTML
<tr bgcolor="#FFFFFF"> <td><input type="checkbox" name="iswrite" onclick="ischeck()" id="iswrite"value="0">自定義輸入</td> </tr> <tr bgcolor="#FFFFFF"> <td><input name="" id="show" type="text" disabled="disabled" value="" size="20" /> </tr>