What are the different types of inputs in HTML forms?

Form inputs are used to collect data from users. They include text boxes, checkboxes, radio buttons, file upload fields, password inputs, date pickers, and so much more. Learn how they work and what each element does.

To know more how to create a form from scratch check my tutorial: Make forms with HTML.

In this article we’ll take a look at the different inputs that a form can have.

Different Form inputs

a)- input type text

The input type text defines a text input that the user should enter.

version="2">
HTML
<form>

      <label> Name: <input type="text"></label>
      
</form>

In the browser we have:

_incontent_7 - incontent_7 -->
<input> type text

b)- input type password

the input type password allows to the user to enter their password.

serter-version="2">
HTML
<form>

      <label> Password: <input type="password"></label>
      
</form>

In the browser we have:

<input> type password

c)- input type checkbox

input type checkbox creates checkboxes in case if there are multiple choices to offer to the user.

HTML
<form>

      <label> Banana: <input type="checkbox"></label>
      
      <label> Apple: <input type="checkbox"></label>
      
</form>

In the browser we have:

<input> type checkbox

d)- input type radio

Similar to input type checkbox, input type radio creates radio buttons in case if there are multiple choices to offer to the user.

HTML
<form>

      <label> Fruit: <input type="radio"></label>
      
      <label> Vegetables: <input type="radio"></label>
      
</form>

In the browser we have:

<input> type radio

e)- input type email

input type email is used for input fields that should contain email. If the input containes other thing than an email the form will not be submitted.

HTML
<form>

      <label> Email: <input type="email"></label>
      
</form>

In the browser we have:

<input> type email

f)- input type file

input type file allows the user to upload documents and images.

HTML
<form>

      <label> Upload: <input type="file"></label>
      
</form>

In the browser we have:

<input> type file

g)- input type color

input type color is used to choose a color.

HTML
<form>

      <label> Color: <input type="color"></label>
      
</form>

In the browser we have:

<input> type color

h)- input type date

input type date is used toselect a date.

HTML
<form>

      <label> Date: <input type="date"></label>
      
</form>

In the browser we have:

<input> type date

i)- input type month

input type month allows the user to select a month and a year.

HTML
<form>

      <label> Month: <input type="month"></label>
      
</form>

In the browser we have:

<input> type month

j)- input type week

week input allows the user to select a week and a year.

HTML
<form>

      <label> Week: <input type="week"></label>
      
</form>

In the browser we have:

<input> type week

k)- input type url

input type url is used to add a URL.

HTML
<form>

      <label> URL: <input type="url"></label>
      
</form>

In the browser we have:

<input> type url

l)- input type time

time input allows the user to choose a time, either AM or PM.

HTML
<form>

      <label> Time: <input type="time"></label>
      
</form>

In the browser we have:

<input> type time

m)- input type tel

input type tel is used to add a phone number.

HTML
<form>

      <label>Phone: <input type="tel"></label>
      
</form>

In the browser we have:

<input> type tel

n)- input type range

range input allows the user to choose a number between 0 and 100.

HTML
<form>

      <label>Range: <input type="range"></label>
      
</form>

In the browser we have:

<input> type range

o)- input type search

search input acts like a search bar.

HTML
<form>

      <label>Search: <input type="search"></label>
      
</form>

In the browser we have:

<input> type search

p)- input type reset

reset input will create a reset button that, when clicked, will refresh the form values. So no need to refresh the browser to reset the form values.

HTML
<form>

      <label>Reset: <input type="reset"></label>
      
</form>

In the browser we have:

<input> type reset

q)- input type submit

A submit input will create a button that, when clicked, submits the form to the server.

HTML
<form>

      <label>Submit: <input type="submit"></label>
      
</form>

In the browser we have:

<input> type submit

r)- input type image

image input creates an image as a submit button.

HTML
<form>

      <label>Image Submit: <input type="image" src="arrow.jpg" alt="Submit"></label>
      
</form>

In the browser we have:

<input> type image

Conclusion

In conclusion, forms allow users to submit information about themselves to websites. They’re also used by search engines to index sites and understand their structure.

You should now know the different inputs that you can use with a Form.

Read More

No post found!

Get new content delivered directly to your inbox

Leave a Reply

%d bloggers like this: