Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the methods of disabling form controls in HTML

Shulou Source: shulou.com Published: 2022-06-01 04:33:56 11月06日 Update

This article introduces the relevant knowledge of "what are the methods of disabling form controls in HTML". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

There are two disabled methods in html, they are:

1. Add a readonly='readonly' attribute to the control label

two。 Add a disabled='disabled' attribute to the control label

For example:

Both of the controls in the example are immutable. But there are some differences between them!

From the literal meaning, we know that the control that tries the readonly property is "read-only", while the trial disabled is "disabled." So what's the difference between them?

Read-only controls (controls that use the readonly property) are not allowed to change their values with the mouse and keyboard, but programmers can use javascript to modify them, and when the form is submitted, the control's name and value are submitted to the server, that is, visible to the server.

The disabled controls (controls that use the disabled property) not only cannot be modified with the mouse and keyboard, but also are invisible to the server, that is, when the form is submitted, its name and value will not be submitted to the server, of course, programmers can also use javascript to modify its value.

This is the difference between them, after knowing the difference, we should know when to use which method, must not be blind!

This is the end of the content of "what are the ways to disable form controls in HTML?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Controls properties methods forms servers services time content more tags users knowledge programs programmers keyboards mice utility learning and then two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi Shulou Technology Apple Huawei