亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
HTML original forms and form controls
label element
Button element
select and option elements
HTML5 enhanced textarea
fieldset and legend elements
HTML's new form attributes
form's form attributes
formaction attribute
formxxxx attribute
autofocus attribute
placeholder attribute
list attribute
autocomplete attribute
The control attribute of label
The labels attribute in the form
The selectionDirection attribute in the text box
HTML5 new form element
Function-rich input element
output element
meter element
progress
HTML5’s new client-side validation
Use validation attributes to perform validation
Call the checkValidity method for verification
Turn off verification
Home Web Front-end HTML Tutorial Comprehensively organize elements related to form forms!

Comprehensively organize elements related to form forms!

Aug 05, 2022 am 11:45 AM
form

HTML original forms and form controls

form elements

elements will not generate visual parts. You can pin core content such as id, class, style, etc., and also specify event attributes such as onclick.

In addition, it also includes action (specifies the address to which the form jumps when the button is confirmed in the stand-alone table), method (specifies what type of request is sent when submitting the form, the value can be get or post ), enctype (specify the character set used to encode the expression content), name (specify the unique name of the form), target (specify which method is applicable to open the target URL). [Recommended: HTML video tutorial]

input element

element is the most versatile among form control elements , the following are produced by several input elements:

Password input box:

<input id="password" name="password" style="password" />

Hidden field:

<input id="hidden" name="hidden" style="hidden" />

Radio button box

<input id="radio" name="radio" style="radio" />

Check box

<input id="checkbox" name="checkbox" style="checkbox" />

Image domain

<input id="image" name="image" style="image" />

File upload domain

<input id="file" name="file" style="file" />

Submit button

<input id="submit" name="submit" style="submit" />

Reset button

<input id="reset" name="reset" style="reset	" />

No action button

<input id="button" name="buton" style="button" />

Some focus attributes

checked: Set whether the radio button and check box are initially selected. .
disabled: Use this element when setting the first load.
maxlength: This attribute is a number that specifies the maximum number allowed to be entered in the text box.
readonly: The value in the specified text box is not allowed to be modified by the user (can be modified using js script). This attribute is an attribute that supports boolean values, indicating that the value of the element is read-only.
size: The value of this attribute is a number that specifies the width of the calcium element.
src: Specify the URL of the image displayed in the image field.
width: Specify the width of the image displayed in the image field.
heigeht: Specify the height of the image displayed in the image field.

label element

The label element can specify core attributes such as id, class, style, etc., and can also specify event attributes such as onclick. In addition, you can also specify a for attribute, which specifies which form control the label is associated with. The usage is for="", and the id of the related control is in the quotation marks.

Button element

element is used to define a button. You can specify core familiarity such as id, class, style, etc., and you can also define event attributes such as onclick. In addition, you can also specify the following elements.

disabled: Specifies whether to disable this button.
name: Specify a unique name for the button. The attribute name should be consistent with the id.
type: Specifies the type of button this button belongs to. The attribute value can only be one of button, reset or submit.
value: Specify the initial value of the button. Can be changed via js script.

select and option elements

elements are used to create list boxes or drop-down menus. The calcium element must be combined with the element. Each The element represents a list item or menu item.
The element can specify core attributes such as id, class, style, etc. This element can specify the onchange event attribute - when the selected option in the list box or drop-down list item changes, onchange is triggered. event.

In addition, the element can also specify the following attributes.

disabled: Set to disable the list box and drop-down menu. The value of this attribute can only be disabled or the attribute value is omitted.
multiple: Set whether the list box and drop-down menu allow multiple selections. Once set to allow multiple selections, the element will automatically generate a list box.
size: Specify how many list items the list box and drop-down menu can implement at the same time. Once set to allow multiple selections, the element will automatically generate a list box.

In the element, only the following two sub-elements can be included.

: used to define list items or menu items. This element can only contain text content as the text for this option.
: used to define list items or menu line groups. This element can only contain child elements.

The element can specify core elements such as id, class, style, etc. It can also specify event attributes such as onclick.

In addition, you can also define the following elements.

disabled: Specifies to disable this option. The value of this attribute can only be disabled.
selected: Specifies whether the initial state of the flow box is selected. The value of this attribute can only be selected.
value: Specify the request parameter value corresponding to this option.

The element can specify core attributes such as id, class, style, etc. It can also specify event response attributes such as onclick. In addition, there are the following attributes.

label: Specify the label of this option group. This attribute is required.
disabled: Set to disable all options in this option group. The attribute value can only be disabled or omitted.

HTML5 enhanced textarea

element is used to generate multi-line text areas. You can specify core elements such as id, class, style, etc., and you can also specify event attributes such as onclick. Due to the special nature of textarea, it can receive user input, and users can select text in the text area. Therefore, you can also specify two attributes, onselect and onchange, which apply to the time when the text area is selected and when the text is modified. In addition to this, this element can also specify the following elements.

cols: Specifies the width of the text field, which is required.
rows: Specifies the height of the text, which is required.
disabled: Specifies that this text field is disabled. The attribute value can only be disabled.
readonly: The specified text field is read-only. The value of this attribute can only be readonly.
maxlength: Set the maximum number of characters that can be entered in the multi-line text field.
wrap: Specify whether to add line breaks to multi-line text fields. This attribute supports two attribute values: soft and hard. If the attribute value is set to hard, the cols attribute must be specified. If the input characters exceed the width specified by cols and cause the text to wrap, then the multi-line text field will automatically add a line break at the line break when the form is submitted.

fieldset and legend elements

elements can be used to group form elements within a form. , this element can specify core elements such as id, class, style, etc., and can also specify the following three attributes.

name: Specify the name of the element.
form: The attribute value of this attribute must be an id with a valid element, which is used to specify that the element belongs to the form.
disabled: This attribute is used to disable the form element. This property is a property that supports boolean values.

HTML's new form attributes

form's form attributes

html5 has added form attributes to all form controls, so it is more flexible when defining form controls on the page , you can prevent and arrange form controls at will, which provides greater flexibility in page layout.

formaction attribute

html5 In order to deal with the problem that the same form contains both registration and login buttons, formaction can be specified for sumit, reset, and image. This attribute can dynamically change the form Submit to a different URL.

formxxxx attribute

The formxxxx attribute is similar to the formaction attribute. For sumit, reset, and image, you can specify formenctype, formmethod, formtarget and other attributes, among which:

formenctype : This attribute allows the button to dynamically change to the enctype attribute.
formmethod: This attribute allows the button to dynamically become a method attribute.
formtarget: This attribute allows the button to dynamically become the target attribute.

autofocus attribute

This is a very commonly used attribute. Its function is to automatically focus on the corresponding position when opening a web page. The usage is to add it to the corresponding code, such as: <input type="password" name="name" autofocus />The function of autofocus in this code is to automatically focus on the page when opening the web page. Password box.

placeholder attribute

This attribute is also very commonly used. Its function is to give corresponding prompts in the text box where the user inputs data, such as: <input type="text " name="username" palceholder="Please enter the user name" />;The role of the palceholder in this code is to display please enter the user name when the user has not entered data in the text box, making the page more user-friendly. .

list attribute

This attribute is also very practical. Before the html5 specification, there was no component similar to ComboBox in the html form attribute. The list attribute of html5 just makes up for this shortcoming. The value of the list attribute should be the ID of a component, which means that the list must be used in conjunction with the element.

The element is equivalent to an invisible element, used to generate a hidden drop-down menu. can contain the same child elements as the element. This element is used in conjunction with the specified element with the list attribute. When the text box of the list attribute is double-clicked, the drop-down menu generated by is displayed.

autocomplete attribute

This option is used to control whether to automatically display the previous filling history when clicking on the text box. The browser activates this function by default. This attribute supports two attribute values:

on: Turn on autocomplete, and a drop-down menu will be displayed below the text box.
off: Turn off autocomplete, the drop-down menu will not be displayed below the text box.

The control attribute of label

html5 provides a control attribute for the element, which is used to access the element associated with it in the javascript script Form elements.

The labels attribute in the form

There is a one-to-many relationship between the form element and the element, and the element obtains his association The form element applies the control attribute, and the form element obtains the element associated with it and applies the labels attribute.

The selectionDirection attribute in the text box

html5 adds a new selectionDirection read-only attribute for single-line text boxes and multi-line text fields. This attribute is used to return the text direction in the text box.

  • When the user selects text in the forward direction, the return value is forward
  • When the user selects text in the reverse direction, the return value is backward
  • When the user does not select text, the return value is forward The value is the last selection made by the user

HTML5 new form element

Function-rich input element

HTML5 is the element The following new possible types have been added.

color: Generate a color selector, the value of value is a color value in the form #xxxxxx.
date: Generate a date picker.
time: Generate a time selector.
datetime-local: Generate a local date and time selector.
week: Generate a text box for the user to select the week.
month: Life is a month selector.
max: The maximum value of the specified date and time.
step: Specify the step size of date and time.
email: Generate an E-mail input box, and the browser will automatically check whether the entered E-mail conforms to the format.

multiple: This attribute supports boolean type. If this attribute value is specified, it means that multiple email addresses are allowed to be entered, separated by English commas.

tel: Generate a text box for entering a phone number.
ur: Generate a text box for inputting a URL, and the browser will automatically check whether the entered URL conforms to the format.
number: Generate a text box that can only enter numbers.

min: The minimum value of the specified value.
max: The maximum value of the specified value.
step: Specify the step size of the number.

range: Generate a drag bar with the following attributes:

min: The minimum value of the drag bar.
max: The maximum value of the drag bar.
step: Specify the step size of the drag bar.

search: Generate a text box specifically for entering search keywords.

output element

HTML5 adds a new form control, which is used to display output. In addition to specifying core attributes such as id, class, and style, this element can also specify the following attributes.

for: This attribute will display the value of that element or those elements when braking the element.

meter element

HTML5 also adds a new element, which represents a counting meter with known maximum and minimum values. In addition to defining core features such as id, class, style, etc., this element can also define the following attributes.

value: Specify the current value of the counting instrument. The default is 0.
min: Specifies the minimum value of the counting instrument, the default is 0.
max: Specifies the maximum value of the counting instrument. The default is 1.
low: Specifies the minimum value of the specified range of the counting instrument, which must be greater than or equal to the value of min.
high: Specify the maximum value of the specified range of the counting instrument, which must be less than or equal to the value of max.
optimum: Specify the optimal value of the effective range of the counting instrument.

progress

element is used to represent a progress bar. In addition to specifying core attributes such as id, class, and style, this element can also specify the following attributes.
max: Specifies the value when the progress bar is completed.
value: Specify the current completed progress value.

HTML5’s new client-side validation

Use validation attributes to perform validation

HTML5 adds the following validation attributes to form controls.

required: This attribute specifies that the form control must be filled in.
pattern: This attribute specifies that the value of the form control must conform to the specified regular expression.
min, max, step: These three attributes are only valid for elements of numerical type and date type. This element must be between min~max and conform to step step length.

Call the checkValidity method for verification

  • If the form returns true by calling the checkValidity() method, it means that the input of all form elements in the form is valid

  • If the form object calls the checkValidity() method and returns true, it means that all the form elements of the expression pass the input verification.

Turn off verification

  • Add the novalidate attribute to the element, which is an attribute that supports boolean values.

  • Set the formnovalidate attribute for submit and button elements. When the user submits the form through the submit button, the form will turn off the verification function.

The above is the detailed content of Comprehensively organize elements related to form forms!. For more information, please follow other related articles on the PHP Chinese website!

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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

PHP Tutorial
1488
72
Applying Semantic Structure with article, section, and aside in HTML Applying Semantic Structure with article, section, and aside in HTML Jul 05, 2025 am 02:03 AM

The rational use of semantic tags in HTML can improve page structure clarity, accessibility and SEO effects. 1. Used for independent content blocks, such as blog posts or comments, it must be self-contained; 2. Used for classification related content, usually including titles, and is suitable for different modules of the page; 3. Used for auxiliary information related to the main content but not core, such as sidebar recommendations or author profiles. In actual development, labels should be combined and other, avoid excessive nesting, keep the structure simple, and verify the rationality of the structure through developer tools.

Implementing Clickable Buttons Using the HTML button Element Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM

To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this

Configuring Document Metadata Within the HTML head Element Configuring Document Metadata Within the HTML head Element Jul 09, 2025 am 02:30 AM

Metadata in HTMLhead is crucial for SEO, social sharing, and browser behavior. 1. Set the page title and description, use and keep it concise and unique; 2. Add OpenGraph and Twitter card information to optimize social sharing effects, pay attention to the image size and use debugging tools to test; 3. Define the character set and viewport settings to ensure multi-language support is adapted to the mobile terminal; 4. Optional tags such as author copyright, robots control and canonical prevent duplicate content should also be configured reasonably.

Best HTML tutorial for beginners in 2025 Best HTML tutorial for beginners in 2025 Jul 08, 2025 am 12:25 AM

TolearnHTMLin2025,chooseatutorialthatbalanceshands-onpracticewithmodernstandardsandintegratesCSSandJavaScriptbasics.1.Prioritizehands-onlearningwithstep-by-stepprojectslikebuildingapersonalprofileorbloglayout.2.EnsureitcoversmodernHTMLelementssuchas,

HTML for email templates tutorial HTML for email templates tutorial Jul 10, 2025 pm 02:01 PM

How to make HTML mail templates with good compatibility? First, you need to build a structure with tables to avoid using div flex or grid layout; secondly, all styles must be inlined and cannot rely on external CSS; then the picture should be added with alt description and use a public URL, and the buttons should be simulated with a table or td with background color; finally, you must test and adjust the details on multiple clients.

How to associate captions with images or media using the html figure and figcaption elements? How to associate captions with images or media using the html figure and figcaption elements? Jul 07, 2025 am 02:30 AM

Using HTML sums allows for intuitive and semantic clarity to add caption text to images or media. 1. Used to wrap independent media content, such as pictures, videos or code blocks; 2. It is placed as its explanatory text, and can be located above or below the media; 3. They not only improve the clarity of the page structure, but also enhance accessibility and SEO effect; 4. When using it, you should pay attention to avoid abuse, and apply to content that needs to be emphasized and accompanied by description, rather than ordinary decorative pictures; 5. The alt attribute that cannot be ignored, which is different from figcaption; 6. The figcaption is flexible and can be placed at the top or bottom of the figure as needed. Using these two tags correctly helps to build semantic and easy to understand web content.

What are the most commonly used global attributes in html? What are the most commonly used global attributes in html? Jul 10, 2025 am 10:58 AM

class, id, style, data-, and title are the most commonly used global attributes in HTML. class is used to specify one or more class names to facilitate style setting and JavaScript operations; id provides unique identifiers for elements, suitable for anchor jumps and JavaScript control; style allows for inline styles to be added, suitable for temporary debugging but not recommended for large-scale use; data-properties are used to store custom data, which is convenient for front-end and back-end interaction; title is used to add mouseover prompts, but its style and behavior are limited by the browser. Reasonable selection of these attributes can improve development efficiency and user experience.

How to handle forms submission in HTML without a server? How to handle forms submission in HTML without a server? Jul 09, 2025 am 01:14 AM

When there is no backend server, HTML form submission can still be processed through front-end technology or third-party services. Specific methods include: 1. Use JavaScript to intercept form submissions to achieve input verification and user feedback, but the data will not be persisted; 2. Use third-party serverless form services such as Formspree to collect data and provide email notification and redirection functions; 3. Use localStorage to store temporary client data, which is suitable for saving user preferences or managing single-page application status, but is not suitable for long-term storage of sensitive information.

See all articles