Form input attributes

The name attribute

Each input field must have a name attribute in order for its value to be submitted.
The information in fields that do not have a name attribute is not passed when submitting a form.

So, the simplest input would be:

<input  type="text" name="firstname"/>

Other attributes 

autofocus: will display the "focus" of the cursor to that field when the page loads. Typically, we chose to bring focus to the first input field of the form,

<input  type="text" name="firstname" autofocus="autofocus"/>

value: specifies the initial value for an input field, 

<input  type="text" name="firstname"  value="Vasilis"/>

 size: specifies the size (in characters) for the input field, 

<input  type="text" name="firstname"  value="Vasilis" size="50"/>

placeholder: a sample value or a short description of the information that we want our user to fill, 

<input  type="text" name="firstname"   placeholder="Your name goes here"/>

minlength: specifies the minimum allowed length for the input field, 

<input  type="text" name="firstname"  placeholder="Your name goes here"  minlength="5"/> 

required: specifies that an input field must be filled out before submitting the form, 

<input  type="text" name="firstname"  placeholder="Your name goes here"  minlength="10" required/>

 

You may have noticed that at first sight, some of these attributes seem to have the same functionality. However, in the next submodule, we will learn how each of these different from one another and why we need all of them.

For more information: https://www.w3schools.com/html/html_form_attributes.asp