ASP普通防爆pression验证的多行文本框 [英] ASP Regular Expression Validator for Multi-line textbox

查看:110
本文介绍了ASP普通防爆pression验证的多行文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要验证的文本框输入的长度。

I need to validate the length of input of a textbox.

最大长度属性并不多行文本框工作。

The max length property does not work for Multiline textboxes.

常规前pression我拥有的是:

The regular expression I have is:

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
                            ErrorMessage="The notes has exceeded maximum length."
                            ControlToValidate="txtNotes" Display="Dynamic"
                            ValidationExpression=".{0,500}" ValidationGroup="PO">
                            *</asp:RegularExpressionValidator>

我遇到的问题是,当一个新行输入到验证报告问题的文本框。

The problem I'm having is when a new line is entered into the textbox the validator reports a problem.

我需要添加到ValidationEx pression忽略回车?

What would I need to add to the ValidationExpression to ignore carriage returns?

感谢

推荐答案

修改 {0,500} [\\ S \\ S] {0,500 } 。需要注意的是回车将不完全是的忽略; 的他们还是会朝500个字符的限制数。

Change .{0,500} to [\s\S]{0,500}. Note that carriage returns won't exactly be ignored; they'll still count toward the 500-character limit.

当然,如果500个字符是数据库字段的大小,这正是你想要的行为。

Of course, if 500 characters is the size of your database field, that's exactly the behavior you want.

这篇关于ASP普通防爆pression验证的多行文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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