Home > Web Front-end > HTML Tutorial > How to limit the number of characters entered in a text area in an HTML form?

How to limit the number of characters entered in a text area in an HTML form?

王林
Release: 2023-08-30 11:17:02
forward
2082 people have browsed it

How to limit the number of characters entered in a text area in an HTML form?

In HTML, we can create forms with the help of various elements to accept and store information entered by users. These elements are also called form elements, such as: text fields (text boxes), radio buttons, check boxes, drop-down or combo boxes, reset and submit buttons.

TextArea is one of the elements that can be created in a form. A text area is used as a multi-line control where users can enter data in multiple rows and columns.

TextArea control is used to enter notes, suggestions, address information, email text, comments, etc. The text size is larger than the ordinary text field because the text field is a single-line input control and requires one line of data.

Example

Let’s understand the basic HTML code to create a text area with default width and height.

<html>
<head><title>Feedback Form..</title>
   <style>
      h1{font-family:Algerian;font-size:20;color:blue;text-align:center}
   </style>
</head>
<body>
   <h1>Feedback Form..</h1>
   <form id="feedback_form">
      <label for="label1">Enter your feedback here:</label>
      <textarea id="t1"> </textarea>
   </form>
</body>
</html>
Copy after login

Example

To set the width and height of a text area of ​​your own choosing, you specify the desired number of rows and columns. To do this, we can make use of the rows and cols attributes of the