如何设置多行文本框的限制 [英] How to set the limit for multiline textbox

查看:146
本文介绍了如何设置多行文本框的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用MultiLine Textbox现在我想允许其中的所有字符,我还想将文本框的限制设置为150个字符。所以我想使用正则表达式,所以任何人都可以帮助我。

i使用这个正则表达式:



^ [A-Za !-z0-9\s @#$%^&*()_ + = - `〜\\\] \ [{} |';:/?,><] * { 1,150} $



所有工作正常,但不限制字符150



谢谢提前。

Hi,
I am Using MultiLine Textbox now i want to allow all the characters in it and also i want to set the limit of the textbox to 150 characters. So iwant to use the regular expression so any one can help me.
i am using this regular expression:

"^[A-Za-z0-9\s!@#$%^&*()_+=-`~\\\]\[{}|';:/.,?><]*{1,150}$"

All working fine but it does not limit the characters to 150

Thanks in advance.

推荐答案

%^&*()_ + = - `〜\\\] \ [{} |';:/。, ?><] * {1,150}
%^&*()_+=-`~\\\]\[{}|';:/.,?><]*{1,150}






所有工作正常,但不会将字符限制为150



提前致谢。
"

All working fine but it does not limit the characters to 150

Thanks in advance.


<script language=JavaScript>
<!-- Beginning of JavaScript -
function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        countfield.value = maxlimit - field.value.length;
    }
}
//  End -->>
</script>
<html>
    <head>
        <meta name="GENERATOR" Content="ASP Express 4.5">
        <title>Untitled</title>
    </head>
    <body>
        <form id="form1" Runat="server">
            Characters Left:
                <asp:TextBox

                    BackColor="Blue"

                    BorderStyle="None"

                    Width="30"

                    ForeColor="White"

                    Font-Bold="True"

                    id="txtLen"

                    Runat="server" Text="100" /><br>
            Enter comments:<br>
            <asp:TextBox id="txtmessage"

                Columns="40" Rows="4"

                TextMode="MultiLine"

                onkeydown="textCounter(this.form.txtmessage,this.form.txtLen,100)"

                onkeyup="textCounter(this.form.txtmessage,this.form.txtLen,100)"

                Runat="server" />
        </form>
    </body>
</html>


这篇关于如何设置多行文本框的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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