简体   繁体   English

asp.net RegularExpressionValidator在多行文本框中不起作用

[英]asp.net RegularExpressionValidator not working in mulitline textbox

I am using RegularExpressionValidator to stop the user from using the apostrophe (symbol '). 我正在使用RegularExpressionValidator来阻止用户使用撇号(符号')。 This is working fine in single line textbox. 在单行文本框中运行正常。 But it always shows error message when the user uses the enter key for new line. 但是,当用户将Enter键用于新行时,它始终显示错误消息。 The ValidationExpression I am using is:ValidationExpression="^(?:(?!['].))*$" 我正在使用的ValidationExpression是:ValidationExpression =“ ^(?:(?![']。))* $”

And this is the code: ErrorMessage="You are not allowed to use apostorphene" ControlToValidate="tbDrivingLicenseOther" 这是代码:ErrorMessage =“您不允许使用撇号” ControlToValidate =“ tbDrivingLicenseOther”
ValidationExpression="^(?:(?!['].))*$"> ValidationExpression =“ ^(?:(?![']。))* $”>

Can not find the solution anywhere on the web. 在网络上的任何地方都找不到解决方案。 Can anyone help? 有人可以帮忙吗?

It isn't clear for me, what are you actually trying to prevent along with apostrophs with your current RegEx... but the following expression: 对我来说还不清楚,您实际上是在尝试使用当前RegEx的撇号来防止什么……而是以下表达式:

ValidationExpression="^[^']*$"

prevents input of apostrophes only in both TextBox and multi-line TextBox. 防止仅在TextBox和多行TextBox中都输入撇号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM