HTML and Limiting Character in a Textarea

By adding the attribute maxlength=”23″ you can limit the field to 23 characters. The browser won’t allow the user to enter anything longer than the number you specify. For those of you with recent versions of Firefox or Chrome, you can try out the demo:

 

As you may notice, I also am making use of a HTML 5 attribute: placeholder. This lets you state text that should be displayed in an input before a user enters data.

This entry was posted in Html and tagged , , , , , . Bookmark the permalink.

2 Responses to HTML and Limiting Character in a Textarea

  1. Benny says:

    Hi Daniel

    The maxlength attribute isn’t a new one that comes with HTML5.
    I have been using it within the last 10 years, I think. :)

    Regards
    Benny

  2. daniel says:

    Good point. The max and min attributes are new, but you are correct in saying that max length already existed. I have updated the post accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>