Link to home
Start Free TrialLog in
Avatar of pinky1307
pinky1307

asked on

I am adding regular expressions dynamically. I have to write the validation expression in code behind. But when i add the expression, it says, invalid escape sequence. What can i do??

I am adding regular expressions dynamically. I have to write the validation expression in code behind. But when i add the expression, it says, invalid escape sequence. What can i do??
Avatar of ozo
ozo
Flag of United States of America image

what expression do you write?
Avatar of pinky1307
pinky1307

ASKER

"^[+-]?\d+(\.\d+)?$"
Thanks for the reply. for integer or float values and for integer or decimal values. it takes "." and "\" as escape sequences
RegularExpressionValidator rv = new RegularExpressionValidator();
                                rv.ID = rev;
                                rv.ControlToValidate = tb.ID;
                                rv.ErrorMessage = "Must be an integer ";
                                rv.Text = "*";
                                rv.ValidationExpression = ("^[+-]?\d+(\.\d+)?$");

this is the code i use.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.