Dwza
Dwza

Reputation: 6565

How to set max value length for div with attribute contenteditable

Actually there are some attributes for input fields...

One of these attributes is maxlength that denies the user to input more characters or numbers than specified.

Is there a way to set a attribute like this to a div that has the property contenteditable ?

Of course I could write a jquery or javascript function to get this done but I was wondering if there is a property like this. And I think, it is not necessary to re-invent the wheel :)

Upvotes: 0

Views: 842

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

The answer is NO. From the docs, maxlength only works for input type.

The maxlength attribute specifies the maximum number of characters allowed in the <input> element.

You need to use some scripting language(like javascript and jquery which you already did) to make it work on contenteditable div.

Upvotes: 3

Related Questions