FILE VALIDATION

To make a file input required, use the R validation rule.

Here are some of the attributes needed to validate a file.

ACCEPT

Use this attribute to list out the file extensions allowed for upload.

POSSIBLE VALUES

.png, .jpg, .jpeg


ACCEPT-MIME

Use this attribute to list out the file MIME types allowed for upload. This attribute also supports MIME types with wildcards.

POSSIBLE VALUES

image/png, image/jpg, image/jpeg or image/*

We recommend that you use accept-mime attribute to check for the file types of selected files, because an end user can rename a file to have an extension outside its original file type.


SIZE

Use this attribute to validate the selected file(s) size. If you provide 5MB, it means that the file selected by the user must be 5MB in size.

It is compatible with both single and multiple file upload inputs.

POSSIBLE VALUES

10MB


MINSIZE

Use this attribute to validate the minimum size of the selected file(s). If you provide 5MB, it means that the file selected by the user must be 5MB in size or more.

It is compatible with both single and multiple file upload inputs.

POSSIBLE VALUES

10MB


MAXSIZE

Use this attribute to validate the maximum size of the selected file(s). If you provide 5MB, it means that the file selected by the user must be 5MB in size or less.

It is compatible with both single and multiple file upload inputs.

POSSIBLE VALUES

10GB

Note that the digital storage supported, ranges from bytes up to petabytes.


FILES

Use this attribute to check the number of files selected by the user. If you provide 5, it means that the user must select 5 files.

This Rule is only supported in multiple file upload input.

POSSIBLE VALUES

5


MINFILES

Use this attribute to check the minimum number of files selected by the user. If you provide 5, it means that the user must select 5 files or more.

This Rule is only supported in multiple file upload input.

POSSIBLE VALUES

10


MAXFILES

Use this attribute to check the maximum number of files selected by the user. If you provide 5, it means that the user must select 5 files or less.

This Rule is only supported in multiple file upload input.

POSSIBLE VALUES

20

Attribute Possible values Custom message
accept .png, .jpg, .jpeg ov-accept-msg
accept-mime image/png, image/jpg, image/jpeg, audio/* ov-accept-mime-msg
size 20Bytes ov-size-msg
minsize 5MB ov-minsize-msg
maxsize 10GB ov-maxsize-msg
files 5 ov-files-msg
minfiles 10 ov-minfiles-msg
maxfiles 30 ov-maxfiles-msg
To prevent the browser from using its inbuilt validation on your form, add the attribute novalidate to the form tag.