Textarea最大长度值不起作用 [英] Textarea maxlength value not working

查看:138
本文介绍了Textarea最大长度值不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本区域,我正在使用DOJO库从JS设置maxlength。代码如下:

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

<textarea id="ct" rows="50" cols="50"></textarea>

在JS中,最大长度设置如下

In JS the max length is setting up as follows

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

我正在使用以下文本填充文本区域。 / p>

I am using the following text to populate textarea.

Twitter's character limit is 140. An SMS text message limit is 160. Google AdSense ads can have 25 characters for the title, 70 characters for the ad text, and 35 characters for the displayed URL. N.B. a space or punctuation are a "character". Exercice: try to copy and paste portions of this text to count the number of letters.  * Even the cheapest online college demands a diploma. Studying an MBA program online or at online business schools requires a previous application where the number of letters is carefully controlled. Admissions to cheapest online college are regulated. Online business schools offer character counts in their advertising classes. An MBA program online offers a wide range of subjects, such as economics, organization, marketing, accounting, finance, strategic management, international business, management of information technology, human resources, and political strategies. Students work on a wide range of courses in the first year, then begin a specialization in the second. Specialization occurs through courses which are generally chosen by the student who wishes to explore a particular area (e.g. the market for finance options or pricing policies for marketing).  * An MBA program online is one of the best in the world. It forms effective frameworks and established many links with the business world. American universities have considerable financial means. For example, Harvard's capital is 34.9 billion. In a federal country like the United States, the university system is decentralized and higher education institutions enjoy considerable autonomy that allows them flexibility.  * Since the mid 1990s, the cheapest online colleges have undergone considerable consolidation. Many providers have gone out of business or were absorbed by larger groups. In 2005, there were 4,182 higher education institutions (colleges, universities, schools) in the United States, and approximately research 1,400 units. That represents the highest enrollment rate in higher education in the world. The two-year online colleges form the basis of tertiary education.  * Online business schools enables Programme graduates to start their professional career abroad. In fact, multiple exchange agreements in many countries place online business schools among the World's most successful. The schools also develop and expand their networks constantly with MBA. The cultural mix is commonplace in the business school, with more than one in three students being from overseas. P

textarea的最大字符数为2500。但是当我在以下URL中粘贴相同的文本时,正在显示2501个字符。这是因为文本中带有*。不确定原因是什么。

The textarea is getting maximum of 2500 characters.But when I paste the same text in following URL it is showing 2501 characters.Is this because of * in the text.Not sure what's the reason.

字符串长度

推荐答案

如果将maxLength替换为2499 ( dojo.attr(el, maxLength,'2499'); )应该可以!

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

因为您必须从0开始计数。

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

希望我帮助了您。

这篇关于Textarea最大长度值不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆