Hello friends In my application I want to customize regular expression in such a way that it will allow character and dot only. For eg. I could be be able to enter M.C.A or MCA any of these. For this ta开发者_C百科sk how to customize regular expression? I tried [a-zA-Z] followed by\ and dot in side bracket but is not working. I also tried [ABCD] just for testing but it shows invalid text for ABC. What might be the reason???? Thanks to all...
You will need to escape the dot as in regex it normally means 'any character'
[a-zA-Z\.]+
in c# you will need to deinfe the regex string as follows:
var r = @"[a-zA-Z\.]+";
Edit based on comment:
<asp:TextBox ID="qualificationBox" runat="server" Width="250px"></asp:TextBox>
<asp:RegularExpressionValidator ID="NameRequiredValidator" runat="server"
ErrorMessage="Please Enter Name" ControlToValidate="qualificationBox"
ValidationExpression="[a-zA-Z\.]+"></asp:RegularExpressionValidator>
You may need to double escape the backslash:
[a-zA-Z\\.]+
精彩评论