Reputation: 4919
For some reasons, I have to use devexpress textbox instead of asp textbox, and the textbox have a validation that the text must contain a ".", so I am using regular expression to validate the user's input like below:
<dx:ASPxTextBox runat="server" ID="textBox1" ValidationSettings-ValidationGroup='<%# Container.ValidationGroup %>'>
<ValidationSettings>
<RegularExpression ValidationExpression="[.]" ErrorText="Invalid input" />
</ValidationSettings>
</dx:ASPxTextBox>
I.e. the regex is very simple, just [.]
I tested the regex on this site http://regexpal.com/
and it's validating properly, but when it's put inside the aspxTextbox, whenever the user type in anything that contains ".", the validation isn't passed (i.e. error text shows), why this happens?
Upvotes: 0
Views: 1819
Reputation: 174696
Just try the below regex to make your validation getting passed.
^.*\..*$
Explanation:
^
- Asserts that we are at the start. For validation purposes, we must give the start and end patterns..*
- Matches any character zero or more times.\.
- Matches a literal dot..*
- Matches any character zero or more times.$
- End of the line.Upvotes: 2