Home Web Front-end H5 Tutorial HTML5 input widgets for creating forms, data binding and data validation

HTML5 input widgets for creating forms, data binding and data validation

Nov 18, 2016 am 11:15 AM
html5

1. Input types and input attributes

 The new input type of HTML5 is given in the novice tutorial. You can try different types on it, which can basically meet your daily development needs. What are the internal differences caused by different types? There are three main points. First, the browser will perform basic data verification based on the input type, such as type="email". If the user input does not include the @ symbol, then this is an illegal input, and the browser will give a corresponding tips. The second impact of different types is that on the mobile terminal, when browsing the page on the browser, if the input item type is different, the virtual keyboard given by the device will be different according to the type. For example, if type="email" , the @ symbol is added to the keyboard type given on the Apple phone when inputting. The third point is the convenience it brings. If the value you input is a color type, then the browser will give you a color selection panel to select or enter the corresponding color. If you implement such a color selector separately, it will be convenient for users. It seems a bit troublesome to enter;.

 Input attributes control some special content. Here are three input attributes:

 placeholder: I believe this attribute is most commonly used by everyone. The accounts and passwords of 126 mailboxes all use this placeholder. Placeholder is actually a text placeholder. When the user enters content, the placeholder automatically disappears and serves as a prompt.

 autofocus: You can understand it by looking at the example. It is used to define the input element that should get focus when the page is loaded.

 Required: Setting this attribute indicates that the input is required. If the user submits the form without filling in the content, the browser will give a corresponding prompt.

2. min max data-*input attribute

 The max min attribute defines the maximum and minimum values ​​of number and range input.

 The function of data-* is to bind key-value pairs to some elements. Obtained through the dataset object of the dom element:

<input type="number" data-price="21" >
js代码:
let element = document.getElementById(&#39;testid&#39;);
let price = element.dataset.price
Copy after login

 The function of the element is to display the results to the user:

<body>
    <output id=&#39;test&#39;>122</output>
</body>
<script type="text/javascript">
    let ss = document.getElementById(&#39;test&#39;)
    ss.value = 888;
</script>
Copy after login

This small example implements setting the output value to 888;

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles