Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I don't want to see 'no file chosen' for a file input field

Tags:

html

jquery

Is there any way where i can stop "no file chosen" for input type file.

<input type="file" id="field-id" name="html" /> 
like image 264
sachin k Avatar asked May 08 '11 11:05

sachin k


People also ask

How do I get rid of no file chosen from input type file?

Remove the value('No file chosen'). Use . addClass() method to add the class which removes the value “No file chosen”.

How do you hide the no file chosen?

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. Then style the label as a button if you want. This even works in IE9, where you can't hide the file input and click it from JavaScript.


1 Answers

You can't get rid of the 'no file chosen' entirely, but you can change the text to something that makes sense by setting the title.

<input type="file" title="foo"> 

will display "foo" on mouseover instead of "no file chosen"

unfortunately,

<input type="file" title=""> 

doesn't work like you might hope.

like image 131
Erich Douglass Avatar answered Sep 21 '22 04:09

Erich Douglass