Languages
[Edit]
EN

HTML - set text input max length

0 points
Created by:
Wiktor-Sribiew
350

In this article, we would like to show you how to set text input element max length in HTML.

Quick solution:

// ONLINE-RUNNER:browser;

<input type="text" name="username" maxlength="10" />

 

Practical example

In this example, we use input element's maxlength attribute to set the maximum number of input element characters.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form>
    <label>
      <span>Username (max 10 characters):</span>
      <input type="text" name="username" maxlength="10" />
    </label>
  </form>
</body>
</html>

References

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join