0

Hello, everyone!

I have a the following regular expression validator:

<asp:RegularExpressionValidator ID="revTime" runat="server" ControlToValidate="txtTime"
ErrorMessage="Time interval must be between 00:00 and 23:59"
ValidationExpression="(^0{0,1}\d:[0-5]\d{0,1}$)|(^[0,1]\d:[0-5]\d(0,1)$)|(^2[0-3]:[0-5]\d(0,1)$)"
Display="Dynamic" />

The validator WORKS. The regular expression works too.

Problem is, the message does not display.

I've tried the following:
* Changing the Display attribute to "Static" or "None";
* Using the Text attribute instead of ErrorMessage;
* Playing around with EnableClientScript (oddly enough, when I set it to "false," the message is displayed, but the validator doesn't prevent submission);
* Banging my head against the table (this actually helps sometimes).

The strangest thing is that I copy-pasted the validator from another page in the project (yes, I renamed the ID and the ControlToValidate!), where the validator works perfectly.
Why does it act differently on this page?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Jinspire
0

Try this,

<asp:RegularExpressionValidator ID="revTime" 
                                runat="server" ControlToValidate="txtTime"
                                ErrorMessage="Time interval must be between 00:00 and 23:59"
                                ValidationExpression="^(?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$"
                                Display="Dynamic" />
0

Thanks for the reply.

There's no problem with the ValidationExpression; it validates the format as it should, and prevents the page from being submitted to the server unless txtTime is inputed correctly.

The problem is the message which simply doesn't show.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.