- Attribute of
- Input As The Fundamental Form Element In HTML: Here's What It Does
- What does
What Input Maxlength Does In HTML: An Easy Tutorialdo?
- Specifies the maximum number of characters that can be entered in a text-type input.
<form> <label for="update">What's your status?</label><br> <input type="text" maxlength="140" id="update" name="update"> </form>
Data validation and
maxlength attribute allows you to specify a maximum number for characters for a text-based input field. This can help usability, such as when you need to limit the length of usernames or other types of input date. However, you should not rely on
maxlength for data validation. While browser support for
maxlength is virtually universal, it is still possible for a malicious (or overly clever) user to bypass your HTML form and submit an HTTP request directly to the server via the form's
action URL. If a too-long input string would break your application in any way, you'll want to do you own server-side data sanitation before simply accepting whatever input comes (apparently) through your form.
Browser Support for maxlength