Input Button required attribute
Definition and Usage
required
Attribute setting or returning whether it is necessary to select/upload a file in the file upload field before submitting the form.
This attribute reflects the HTML required attribute.
See also:
HTML Reference Manual:HTML <input> required Attribute
Example
Example 1
Determine whether it is necessary to select/upload a file before submitting the form:
var x = document.getElementById("myFile").required;
Example 2
Set the file upload field as a required part of the form submission:
document.getElementById("myFile").required = true;
Syntax
Return the required attribute:
fileuploadObject.required
Set the required attribute:
fileuploadObject.required = true|false
Attribute value
Value | Description |
---|---|
true|false |
The specification of whether the file upload field should be a required part of the form submission.
|
Technical Details
Return value: | Boolean value, if the file upload field is a required part of the form submission, it returns true ; Otherwise return false . |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supported | 10.0 | Supported | Not Supported | Supported |