1.

Explain new input types provided by HTML5 for forms?

Answer»

Following are the significant new data TYPES offered by HTML5:

  • Date - Only SELECT date by using type = "date"
  • Week - Pick a week by using type = "week"
  • Month - Only select month by using type = "month"
  • Time - Only select time by using type = "time".
  • Datetime - Combination of date and time by using type = "datetime"
  • Datetime-local - Combination of  date and time by using type = "datetime-local." but ignoring the timezone
  • Color - Accepts multiple colors using type = "color"
  • Email - Accepts one or more email addresses using type = "email"
  • Number - Accepts a numerical value with ADDITIONAL CHECKS like min and max using type = "number"
  • Search - Allows searching queries by inputting text using type = "search"
  • Tel - Allows different phone numbers by using type = "tel"
  • Placeholder - To display a short hint in the input fields before entering a value using type = "placeholder"
  • Range - Accepts a numerical value within a specific range using type = "range"
  • Url - Accepts a web ADDRESS using type = "url”
<form> <div> <label>Date:</label> <input type="date" id="date" /> <br> <label>Week:</label> <input type="week" id="week" /> <br> <label>Month:</label> <input type="month" id="month" /> <br> <label>Time:</label> <input type="time" id="time" /> <br> <label>Datetime:</label> <input type="datetime" id="datetime" /> <br> <label>Datetime Local:</label> <input type="datetime-local" id="datetime-local" /> <br> <label>Color:</label> <input type="color" id="color"/> <br> <label>Email:</label> <input type="email" id="email" placeholder="email address" /> <br> <label>Number:</label> <input type="number" id="number" /> <br> <label>Search:</label> <input type="search" id="search" /> <br> <label>Phone:</label> <input type="tel" id="phone" placeholder="Phone Number" pattern="\d{10}$" /> <br> <label>Range:</label> <input type="range" id="range" /> <br> <label>URL:</label> <input type="url" id="url"/> </div> </form>


Discussion

No Comment Found