zoukankan      html  css  js  c++  java
  • input type=file 标签禁止让用户手动输入

    1. 替代法

          使用隐藏的<input type="file"/>控件,然后用一个只读的文本框和一个按钮来模拟<input type="file"/>的功能。

    <input type="file" name="file" onpropertychange="file1.value=this.value" style=display:none/>   
    <input type="text" name="file1" readonly/>   
    <input type="button" value="浏览" id="button1" name="button1" onclick="file.click()"/>

    2. 使用脚本事件限制控件输入

          将<input type="file"/>控件的鼠标右键菜单、按键事件限制住,不让用户有机会输入。

    <input type="file" onkeydown="return false" onkeyup="return false" oncontextmenu="return false">

    3. 使用contenteditable属性

          使用该属性可以有效地限制用户在<input type="file"/>控件中手动输入内容,而只能通过文件选择对话框选择文件。

    <input type="file" id="file1" contenteditable="false" />
  • 相关阅读:
    sqlserver中压缩日志文件
    git命令的使用
    c#开发wps插件(3)部署
    c#开发wps插件(2)
    小王子
    唯一的!!!
    小王子
    MySql命令行修改密码
    MacOS下Lucene学习
    企业权限管理(SSM整合)(总结)
  • 原文地址:https://www.cnblogs.com/lihaishu/p/4538470.html
Copyright © 2011-2022 走看看