How to prohibit text in html

藏色散人
Release: 2021-05-24 10:21:58
Original
1577 people have browsed it

How to prohibit text in HTML: 1. Use readonly in HTML to prohibit text input; 2. Use disabled in HTML to prohibit text input.

How to prohibit text in html

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

HTML prohibiting text input

In a text box, there are two ways to prohibit text input, one is to use readonly, and the other is to use disabled.

So although the purpose of both Both can be achieved, but from a performance perspective, disabled will appear more intuitive. Why do you say this?

Please see the screenshot:

How to prohibit text in html

As shown in the picture:

1 is readonly, 2 is diabled. Obviously it is modified with diabled The text box turns gray. To sum up, it is recommended to use disabled to make the text box unavailable for input.

But for time frames that cannot be entered, it is more recommended to use readonly.

The corresponding codes are as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <script type="text/javascript" src="../js/lib/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#readonly").prop("readonly", true);
            $("#disable").prop("disabled", true);
        })
    </script>
</head>
<body>
<input id="readonly" type="text">
<input id="disable" type="text">
</body>
</html>
Copy after login

Recommended tutorials: html video tutorial, css video tutorial

The above is the detailed content of How to prohibit text in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template