1

how to make accept attribute accepting css file type or js files ?

<input type="file" name="NAME" id="fileinput2" accept=".css" onchange="check()" />

thank you

S-Deniz
  • 85
  • 1
  • 5

4 Answers4

2

Like this:

<input type="file" name="NAME" id="fileinput2" accept=".css,.js" />

But W3C recommends to specify both MIME-types and corresponding extensions in the accept attribute. So, the best approach would be:

<input type="file" name="NAME" id="fileinput2" accept=".css, .js, text/css, application/x-javascript" />

For complete Mime types Refer this

Ambrish Pathak
  • 3,813
  • 2
  • 15
  • 30
2

You can use comma separated value for accept attribute.

Like this:

<input type="file" name="NAME" id="fileinput2" accept=".css,.js" onchange="check()" />
Srinivas Damam
  • 2,893
  • 2
  • 17
  • 26
1

Separate each extension by a comma

<input type="file" name="NAME" id="fileinput2" accept=".css, .js" onchange="check()" />
Lixus
  • 511
  • 2
  • 12
0

According to MDN the accept attribute accepts a comma separated list.

Richard
  • 106,783
  • 21
  • 203
  • 265