0
   

How to trigger a file browser through keyboard using java script or jquery

 
 
Reply Tue 1 Nov, 2016 05:43 pm
I am using below code:
<label for="imageFileUpload" class="file-button new-gradient " tabindex="0">
<span>
<%=(string.Format("{0}", (UploadedFiles != null && UploadedFiles.Count > 0) ? "Add Documentation" : "Add Receipt" %>
</span>
<asp:FileUpload ID="imageFileUpload" runat="server" type="file" size="10" CssClass="file-upload visually-hidden"
onchange="PerformUpload();" ClientIDMode="Static" />
</label>

Java script code:

$(function() {
$("#imageFileUpload").on("keyup", function (event) {
if (event.keyCode === 13) {
$("input[type = 'file']").click();
}
});
});


I am able to set the focus on the button using tabIndex. When i use keyboard to access the button focus is present but the file browser is not opened. nothing happens when i hit enter from keyboard.

Could you please help me out. Thanks in advance.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 671 • Replies: 0
No top replies

 
 

Related Topics

programming - Question by christina75
JAVA SCRIPT - Question by pranay
java EJB - Question by rockerpham
Help me out... - Question by Prateekr10
 
  1. Forums
  2. » How to trigger a file browser through keyboard using java script or jquery
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/20/2024 at 05:09:03