
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to limit maximum items on multiple input ()?
To allow multiple file uploads in HTML forms, use the multiple attributes. The multiple attributes work with email and file input types.
For limiting maximum items on multiple inputs, use JavaScript. Through this, limit the number of files to be uploaded. For example, let’s say only 2 files to be uploaded at once.
You can try to run the following code to learn how to use multiple attributes in HTML. With that, we will limit the number of files uploaded using JavaScript.
Example
<!DOCTYPE html> <html> <head> <title>HTML file upload</title> </head> <body> <form> <input type="file" action="/action_page.php" name="name" multiple><br/> Upload multiple files, and click Submit.<br> <input type = "submit" value = "submit"> </form> <script> $(function(){ $("input[type = 'submit']").click(function(){ var $fileUpload = $("input[type='file']"); if (parseInt($fileUpload.get(0).files.length) > 3){ alert("You are only allowed to upload a maximum of 3 files"); } }); }); </script> </body> </html>
- Related Articles
- How to limit input text length using CSS3?
- How to limit an HTML input box so that it only accepts numeric input?
- How to give a limit to the input field in HTML?
- How to limit network bandwidth on linux
- How to get the maximum file name length limit using Python?
- Multiple Input Multiple Output (MIMO)
- Multiple WHERE with LIMIT in MySQL?
- How to limit the number of characters allowed in form input text field?
- How to implement multiple input checkbox in vanilla JavaScript?
- How to Select Multiple Files using HTML Input Tag?
- How to remove multiple selected items in the listbox in Tkinter?
- How to correctly select multiple items with the mouse in Tkinter Treeview?
- How to check multiple regex patterns against an input? Using Java.
- How to find pairwise maximum among multiple vectors in R?
- MongoDB find by multiple array items?

Advertisements