Skip to content
This repository was archived by the owner on Feb 3, 2021. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

HTML Forms

Table of Contents

  1. What are forms?
  2. More advance input types

What are forms?

The form tag is used to group certain inputs together to be submitted. This is a way to take input from the user and send it to another file for processing. A sample can be found here.

The <label for="fullname"></label> creates a text label for a certain input. In this case, the for="fullname attribute defines which input the label is bound to (i.e. <input type="text" id="fullname" name="fullname" required>). When the user clicks the label, it will automatically highlight the input with an id matching its for attribute.

The <input type="text" id="fullname" name="fullname" required> allows the user to input data. The type="text" attribute is used to define what type of input is needed from the user (type=”text” is used for plain text inputs). The name="fullname" attribute defines what the value inside the input will be named as once submitted. The required attribute makes it so that the user can’t submit the form while this field is still empty.

The <input type="submit" value="Submit Form"> is the submit button for the form. The type="submit" indicates that this is a submit button. The value="Submit Form" defines what will be written on the button.

Output

More advanced input types

Check the example here

Password inputs

Inputs with type=”password” hide the string written inside them.

Number inputs

Inputs with type=”number” only accept numeric inputs.

Number inputs with step="0.01" accept floating point inputs.

Date inputs

Inputs with type=”date” accepts a formatted date and opens up a calendar when clicked.

Email inputs

Inputs with type=”email” only accepts properly formatted emails.