You are here: Reference > JavaScript > client-side > HTML DOM > properties > accept (form, input:file)
accept property (form, input:file)
Sets or retrieves a comma-separated list of accepted content types.
This property is useful if you want to add a file type filter to the file open dialog.
Although all browsers support the accept property, but only Opera implements its functionality; it has no effect in other browsers.
Although all browsers support the accept property, but only Opera implements its functionality; it has no effect in other browsers.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: accept |
Possible values:
String that sets or retrieves a comma-separated list of media types. See the page for the MIME types for more information.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the accept attribute:
|
||||
<input type="file" size="20" accept="video/mpeg" /> <input type="file" size="20" accept="image/gif" /> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the accept property:
|
||||
<head> <script type="text/javascript"> function GetAccept () { var fileSelector = document.getElementById ("fileSelector"); alert (fileSelector.accept); } </script> </head> <body> The filtering mechanism is only supported by Opera <input type="file" size="20" accept="video/mpeg" id="fileSelector" /> <button onclick="GetAccept ()">Get the accepted file type!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
External links:
User Contributed Comments