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?

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" />

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.