HTML <input> Tag with the 'multiple' Attribute
<form name="myForm" action="/resources/html-forms-action.cfm">
<input type="email" name="emailAddr" size="50" list="contacts" multiple>
<datalist id="contacts">
<option value="homer@simpson.com">
<option value="barney@rubble.ws">
<option value="fred@flinstone.cc">
<option value="peter@griffin.org">
</datalist>
<button>Submit</button>
</form>
<p>Enter multiple email addresses, separated by a comma.</p>
The above example demonstrates usage of the <input>
element with the multiple
attribute.
The multiple
attribute allows you to specify that a field can accept more than one value.
In the above example, the <input>
element has type="email"
. The multiple
attribute allows the user to enter multiple email addresses (separated by a comma). Without the multiple
attribute, the user would get an error when the browser encounters the comma.
You can also use the multiple
attribute on <select>
lists.
Another Example: Uploading Files
You can also use the multiple
attribute to allow the user to select and upload multiple files. Like this:
<form name="myForm2" action="/resources/html-forms-action.cfm">
<input type="file" name="myFile" multiple>
<button>Submit</button>
</form>