Skip to content Skip to sidebar Skip to footer

Textarea Maxlength Value Not Working

I have a textarea and I am setting maxlength from JS using DOJO library.The code is as follows: In JS the max length

Solution 1:

If you replace your maxLength by 2499 (dojo.attr(el,"maxLength",'2499');) it should works !

It's because you have to start counting from 0 !

Hope I've helped you.

Solution 2:

Instead of var max = el.attributes.maxLength.value;

You may use var max = el.attributes.maxLength; Now complete code will be:

var el = dojo.byId('ct');
    if(el){
    dojo.attr(el,"maxLength",'2500');
    if (!('maxLength'in el)) {
var max = el.attributes.maxLength;
el.onkeypress = function () {
    if (this.value.length >= max) returnfalse;
};

Post a Comment for "Textarea Maxlength Value Not Working"