0

I have tested my regular expression in "rubular" and it is passing all my required conditions.But when i use that into asp text box its not passing true.

My Code looks like below

<asp:TextBox ID="MobileNumber" runat="server"></asp:TextBox>
    <asp:RegularExpressionValidator ID="MobileNumberValidater" runat="server" ControlToValidate="MobileNumber" ErrorMessage="Please enter valid Numbers"></asp:RegularExpressionValidator>

My regular expression looks like below

^((0((?=\d* \d*#)[\d ]{,11})(#\d{,5})?)|(0(?:\d{,10})(#\d{,5})?)|(0((?=\d* \d*$)[\d ]{,11})))$

I am trying to validate the following strings:

1).012345 6789#123

2).025698 785#6548

Thanks.

Osiris
  • 4,195
  • 2
  • 22
  • 52
user1863261
  • 107
  • 1
  • 13
  • Here is a useful post: http://stackoverflow.com/questions/1824403/asp-net-regular-expression-validator-client-side-script-error. Ensure "EnableClientScript" is set to false. It might be a good idea to post the server side code aswell. – Daniel PP Cabral Dec 07 '12 at 07:55

1 Answers1

1

A quick check here seems to indicate that the regex you are using is incorrectly formatted for the .Net client. I'm not familiar with Rubular, but it may be that it uses a different regex engine.

I had a play with your regex, but those phone numbers don't look like anything I've seen, so if you're stuck it may be worth taking a look here.

flacnut
  • 1,030
  • 4
  • 11
  • 21