在提交/上传之前如何检查是否使用 t:inputFileUpload 选择了文件
我想知道是否可以在单击提交/上传按钮之前检查是否已选择文件?
我想用此选项解决的问题是,如果尚未选择文件,则隐藏“提交/上传”按钮?使用 required="true"
属性对我来说不是一个选择,因为用户并不总是需要提供文件。
I wanted to know if it is possible to check if a file is already selected prior to a click on submit/upload button?
The problem I want to solve with this option is to hide the "submit/upload" button if no file has already selected? Using required="true"
attribute is not an option for me because the user doesn't always have to provide a file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以通过最初通过 CSS 隐藏上传按钮并将一些 JS 附加到文件字段的
change
事件来实现,该文件字段在选择文件时显示上传按钮。This is possible by initially hiding the upload button by CSS and attaching some JS to the
change
event of the file field which displays the upload button if a file has been selected.