I have a button "Choose file" as follows (I am using Jade but it should be the same as Html5):
input(type='file', name='videoFile')
In the browser this shows a button with a text next to it "No file chosen". I would like to change the "No file chosen" text to something else, like "No video chosen" or "Choose a video please". I followed the first suggestions here:
I don't want to see 'no file chosen' for a file input field
But doing this did not change the text:
input(type='file', name='videoFile', title = "Choose a video please")
Can anybody help me figure out where the problem is?
Remove the value('No file chosen'). Use . addClass() method to add the class which removes the value “No file chosen”.
It's basically impossible to change the text of the native file input button.
Hide the input with css, add a label and assign it to input button. label will be clickable and when clicked, it will fire up the file dialog.
<input type="file" id="files" class="hidden"/> <label for="files">Select file</label>
Then style the label as a button if you want.
Try this its just a trick
<input type="file" name="uploadfile" id="img" style="display:none;"/> <label for="img">Click me to upload image</label>
How it works
It's very simple. the Label element uses the "for" tag to reference to a form's element by id. In this case, we used "img" as the reference key between them. Once it is done, whenever you click on the label, it automatically trigger the form's element click event which is the file element click event in our case. We then make the file element invisible by using display:none and not visibility:hidden so that it doesn't create empty space.
Enjoy coding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With