文本框的正则表达式采用除双引号和单引号之外的所有字符 [英] regular expression for textbox take all character except double quote and single quote
本文介绍了文本框的正则表达式采用除双引号和单引号之外的所有字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本框.此文本框包含除双精度和单精度以外的所有字符
如果我以前写过一些简单的正则表达式,则应该可以使用正则表达式验证器(asp.net)
i have one textbox.This textbox take all character except double and single
quote.how I can do this using regular expression validator(asp.net)
推荐答案
很少的努力.但是,如果您对主题的背景了解有限,建议您先浏览链接.
参考
http://www.regular-expressions.info/reference.html [ http://www.regular-expressions.info/javascript.html [ http://www.regular-expressions.info/javascriptexample.html [
If you wrote some simple regex before, you should be able to do this with a little effort. However, if you have limited background regarding the subject matter, I suggest you go through the links first.
Reference
http://www.regular-expressions.info/reference.html[^]
Regex with Javascript
http://www.regular-expressions.info/javascript.html[^]
Test your regex with this tool
http://www.regular-expressions.info/javascriptexample.html[^]
您也可以使用FilteredTextBoxEntender
来自AjaxControlToolkit
.
然后设置FilteredTextBoxExtender的以下属性
You can also use theFilteredTextBoxEntender
from theAjaxControlToolkit
.
Then set following properties of the FilteredTextBoxExtender
FilterMode = Custom<br />
FilterType = InvalidChars<br />
InvalidChars = ''"
(没有逗号,其他逗号也将被视为无效.)
(without commas else comma will also be considered invalid.)
以下代码可用于禁止TextBox中的和"
The following code can be used to disallow " and '' in TextBox
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage=" and ' are not permitted"
ValidationExpression="[^"']*"></asp:RegularExpressionValidator>
这篇关于文本框的正则表达式采用除双引号和单引号之外的所有字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文