Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the required property in a html5 form

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the required attribute in the html5 form". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the required attribute in the html5 form".

Definition and usage

The required property is a Boolean property

The required attribute states that the input field must be completed before submission.

If you use this property, the field is required (or required).

Note: the required attribute applies to the following types: text, search, url, telephone, email, password, date pickers, number, checkbox, radio and file.

Syntax uses user name

Password

Note:

1:required and required= "required" have the same effect, except that the former is abbreviated.

2: the code must be wrapped in form tags to be effective

3: the button you click must be of type submit. The type of button is invalid.

How to customize the prompt text user name and how to invalidate required

1: change the button type to button instead of submit.

2: add the formnovalidate attribute to the submit button.

User name

Password

3: add a novalidate attribute to the element to disable validation for the entire form.

User name

Password

4Query pattern attribute-validates using regular expressions

(1) it is not necessary to use ^ and $characters to indicate that it is worth the beginning and end of the field to match.

(2) if only pattern is set, the null value will also be passed. If null is not allowed, add the required attribute.

Thank you for your reading, the above is the content of "how to use the required attribute in the html5 form". After the study of this article, I believe you have a deeper understanding of how to use the required attribute in the html5 form. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report