如何为多行TextBox的最大长度? [英] How to set maxlength for multiline TextBox?

查看:206
本文介绍了如何为多行TextBox的最大长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用一个多行TextBox(产生一个TextArea)设置MaxLength属性没有任何效果。什么是最好的解决办法?我想进入不是字符的最大数量更得到基本的,打算与丑陋的javascript等只需prevent用户的最小功能。

When using a MultiLine TextBox (which generates a TextArea) setting the MaxLength property has no effect. What is the best workaround? I'd like to get basic, intended functionality with minimum of ugly javascript etc. Just prevent user from entering more than max number of characters.

推荐答案

如果您希望让用户知道他是否超出字符作为他写道,你可以使用JavaScript函数连接到关键preSS事件的金额。该功能将测试输入的长度和取消字符渲染,如果maxlenght达到。

If you want to let the user know if he exceeded the amount of characters as he writes, you could use a javascript function attached to keypress event. This function would test the length of the input and cancel the character rendering if the maxlenght was reached.

另一种选择是使用 RegularEx pressionValidator 控件来验证上提交的投入。

Another option is to use RegularExpressionValidator control to validate the input on submit.

在我看来,第一个选项是好过得多。

In my opinion, the first option is much more better.

我不加入任何code,因为谷歌是充满了各种口味的例子,这是一个很常见的任务。

I'm not adding any code since google is full of examples for all tastes, this is a very common task.

<一个href=\"https://www.google.com.ar/#hl=es&sclient=psy-ab&q=multiline+textbox+maxlength&oq=multiline+textbox+maxlength&aq=f&aqi=&aql=&gs_sm=3&gs_upl=5132l5288l0l5522l2l2l0l0l0l1l227l227l2-1l1l0&gs_l=serp.3...5132l5288l0l5522l2l2l0l0l0l1l227l227l2-1l1l0.llsin.&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=c452ca4d959557aa&biw=1399&bih=790\">Here你有一个示例搜索可能的帮助。

Here you have a sample search that might help.

这篇关于如何为多行TextBox的最大长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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