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" />
只能输入数字的Input
<input
onkeypress="return (/^(-?\d+)(\.\d+)?$/.test(String.fromCharCode(event.keyCode))) || ( /^(-?\d+)$/.test(this.value) ) "
onpaste="return !clipboardData.getData('text').match(/\D/)"
ondragenter="return false"
style="ime-mode:Disabled"
>
分享到:
相关推荐
如何将input type=file显示的浏览变成英文的,简单实用!
input type=file 调取手机照相机和选择照片上传 附件下载demo导入运行即可
HTML input type=file文件选择表单元素.docx
input type=file 显示的浏览 改成英文
C#如何使用input[type=file]进行多个图片上传(XMLHttpRequest与后台交互) 详情可看:https://blog.csdn.net/weixin_44713389/article/details/90746459
注意:input[type=file] 标签中的属性accept=application/msword,application/pdf 在pc上正常,但是在手机ios和android上这个文件格式限制会被忽略,所以需要在js中增加格式的判断,以及对应显示样式的设置.(我也是刚...
解决在webview中input标签type="file"不能使用的问题
type=file选择图片后,在页面预览显示出来
怎样让input type=file 只读,并能实现文件上传
利用jquery的工具ajaxfileupload.js配合input[type=file]实现无刷新上传文件,内含教程以及支持文件,希望可以帮助各位,谢谢!
android webview input=file 失效解决方案
json struts2 ajax文件上传 input type=file,选择相同文件也提交,里面附带类库,可以直接运行。使用工具, myeclipse
通过网络搜索发现是因为 android webview 由于考虑安全原因屏蔽了 input type=”file” 这个功能 。 经过不懈的努力,以及google 翻译的帮助 在 stackoverflow 中找到了解决的方法。 具体可以理解为 重写webview 的...
input type=”file” name=”uploadfile” contentEditable=”false” style=”width:80%”>, 提交表单时需要判断其中至少要有一个input已经选择好文件。 代码如下: <input type=”file” name=”uploadfile...
自己收集的按钮国际化实现,大家自己看看,应该有用的
input type=”file” name=”file” /> 既然这样我们就用一个text和一个button来显示这个file的样式,html代码是这样: 复制代码代码如下: <div class=”file-box”> <form action=”” method=”post” ...
主要介绍了jQuery实现input[type=file]多图预览上传删除等功能,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
IE11版本好像才兼容input type="number",但是现在Win7版本操作系统下,很多人的IE版本都是IE7/8/9,所以为了体验就自己写了一个小插件,支持设置最大值、最小值、数字间隔。
mui.css和input type=checkbox冲突,导致打不上勾(无法选中)的解决办法.zip
主要介绍了css input[type=file] 样式美化(input上传文件样式 )的相关资料,需要的朋友可以参考下